Skip to content

Commit

Permalink
Use trusted publishing and hatch
Browse files Browse the repository at this point in the history
  • Loading branch information
kislyuk committed Dec 31, 2024
1 parent 0c3b765 commit 3419136
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 55 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Publish release to PyPI

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
pypi-publish:
name: Build and upload release to PyPI
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- run: pip install build
- run: python -m build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
11 changes: 1 addition & 10 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,20 @@ release:
@if ! type -P pandoc; then echo "Please install pandoc"; exit 1; fi
@if ! type -P sponge; then echo "Please install moreutils"; exit 1; fi
@if ! type -P gh; then echo "Please install gh"; exit 1; fi
@if ! type -P twine; then echo "Please install twine"; exit 1; fi
git pull
git clean -x --force $$(python setup.py --name)
sed -i -e "s/version=\([\'\"]\)[0-9]*\.[0-9]*\.[0-9]*/version=\1$${TAG:1}/" setup.py
git add setup.py
TAG_MSG=$$(mktemp); \
echo "# Changes for ${TAG} ($$(date +%Y-%m-%d))" > $$TAG_MSG; \
git log --pretty=format:%s $$(git describe --abbrev=0)..HEAD >> $$TAG_MSG; \
$${EDITOR:-emacs} $$TAG_MSG; \
if [[ -f Changes.md ]]; then cat $$TAG_MSG <(echo) Changes.md | sponge Changes.md; git add Changes.md; fi; \
if [[ -f Changes.rst ]]; then cat <(pandoc --from markdown --to rst $$TAG_MSG) <(echo) Changes.rst | sponge Changes.rst; git add Changes.rst; fi; \
git commit -m ${TAG}; \
git tag --sign --annotate --file $$TAG_MSG ${TAG}
git tag --annotate --file $$TAG_MSG ${TAG}
git push --follow-tags
$(MAKE) install
gh release create ${TAG} dist/*.whl --notes="$$(git tag --list ${TAG} -n99 | perl -pe 's/^\S+\s*// if $$. == 1' | sed 's/^\s\s\s\s//')"
$(MAKE) release-pypi
$(MAKE) release-docs

release-pypi:
python -m build
twine upload dist/*.tar.gz dist/*.whl --sign --verbose

release-docs:
$(MAKE) docs
-git branch -D gh-pages
Expand Down
46 changes: 46 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,49 @@
[project]
name = "PyOTP"
description = "Python One Time Password Library"
readme = "README.rst"
requires-python = ">=3.8"
license = { text = "MIT License" }
authors = [{ name = "Andrey Kislyuk"}, {email = "kislyuk@gmail.com" }]
maintainers = [{ name = "Andrey Kislyuk"}, {email = "kislyuk@gmail.com" }]
dynamic = ["version"]
classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: MacOS :: MacOS X",
"Operating System :: POSIX",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Development Status :: 5 - Production/Stable",
"Topic :: Software Development",
"Topic :: Software Development :: Libraries :: Python Modules",
]

[project.optional-dependencies]
test = ["coverage", "wheel", "ruff", "mypy"]

[project.urls]
"Homepage"= "https://github.com/pyauth/pyotp"
"Documentation"= "https://github.com/pyauth/pyotp"
"Source Code"= "https://github.com/pyauth/pyotp"
"Issue Tracker"= "https://github.com/pyauth/pyotp/issues"
"Change Log"= "https://github.com/pyauth/pyotp/blob/main/Changes.rst"

[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[tool.hatch.version]
source = "vcs"

[tool.black]
line-length = 120

Expand Down
45 changes: 0 additions & 45 deletions setup.py

This file was deleted.

0 comments on commit 3419136

Please sign in to comment.