From 6d7d4220767441b0fb5bf53ee799eb277d81a30a Mon Sep 17 00:00:00 2001 From: Andrey Kislyuk Date: Tue, 31 Dec 2024 18:37:54 -0800 Subject: [PATCH] Use trusted publishing and hatch --- .github/workflows/release.yml | 21 +++++++++++++++ common.mk | 10 +------ pyproject.toml | 46 ++++++++++++++++++++++++++++++++ setup.py | 50 ----------------------------------- 4 files changed, 68 insertions(+), 59 deletions(-) create mode 100644 .github/workflows/release.yml delete mode 100755 setup.py diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..4bdd1ec --- /dev/null +++ b/.github/workflows/release.yml @@ -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 diff --git a/common.mk b/common.mk index 8a98231..cf7fc87 100644 --- a/common.mk +++ b/common.mk @@ -18,11 +18,8 @@ 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 + git clean -x --force watchtower 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; \ @@ -34,13 +31,8 @@ release: 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 --verbose - release-docs: $(MAKE) docs -git branch -D gh-pages diff --git a/pyproject.toml b/pyproject.toml index 5d164c7..2daa0e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,49 @@ +[project] +name = "watchtower" +description = "Python CloudWatch Logging" +readme = "README.rst" +requires-python = ">=3.8" +license = { text = "Apache Software 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 = ["pyyaml", "coverage", "build", "wheel", "ruff", "mypy"] + +[project.urls] +"Homepage"= "https://github.com/kislyuk/watchtower" +"Documentation"= "https://kislyuk.github.io/watchtower" +"Source Code"= "https://github.com/kislyuk/watchtower" +"Issue Tracker"= "https://github.com/kislyuk/watchtower/issues" +"Change Log"= "https://github.com/kislyuk/watchtower/blob/develop/Changes.rst" + +[build-system] +requires = ["hatchling", "hatch-vcs"] +build-backend = "hatchling.build" + +[tool.hatch.version] +source = "vcs" + [tool.black] line-length = 120 diff --git a/setup.py b/setup.py deleted file mode 100755 index fc32dfe..0000000 --- a/setup.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python - -from setuptools import find_packages, setup - -setup( - name="watchtower", - version="3.3.1", - url="https://github.com/kislyuk/watchtower", - license="Apache Software License", - author="Andrey Kislyuk", - author_email="kislyuk@gmail.com", - description="Python CloudWatch Logging", - long_description=open("README.rst").read(), - python_requires=">=3.8", - install_requires=[ - "boto3 >= 1.9.253, < 2", - ], - extras_require={ - "tests": [ - "pyyaml", - "ruff", - "coverage", - "build", - "wheel", - "mypy", - ] - }, - packages=find_packages(exclude=["test"]), - include_package_data=True, - package_data={ - "watchtower": ["py.typed"], - }, - platforms=["MacOS X", "Posix"], - 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 :: Implementation :: CPython", - "Programming Language :: Python :: Implementation :: PyPy", - "Topic :: Software Development :: Libraries :: Python Modules", - ], -)