From 194693439dd1107875c52ba1be892b9eb87560d8 Mon Sep 17 00:00:00 2001 From: Stephane Odul Date: Tue, 13 Feb 2024 12:57:28 -0800 Subject: [PATCH 1/4] Add pypi-publish action. This will allow us to release to pypi directly from the GH UI by simply creating a tagged release. Addresses #278 --- .github/workflows/release-test.yml | 37 ++++++++++++++++++++++++++++++ .github/workflows/release.yml | 37 ++++++++++++++++++++++++++++++ CHANGELOG.md | 3 ++- Makefile | 7 ++++-- green/VERSION | 2 +- release.md | 27 ++++------------------ 6 files changed, 86 insertions(+), 27 deletions(-) create mode 100644 .github/workflows/release-test.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release-test.yml b/.github/workflows/release-test.yml new file mode 100644 index 0000000..8220695 --- /dev/null +++ b/.github/workflows/release-test.yml @@ -0,0 +1,37 @@ +# Keep the content of this file in sync with release.yml. + +name: Release Test +on: + workflow_dispatch: + +jobs: + pypi-publish: + name: Upload release to PyPI + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/green + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: 3.12.2 + + - name: Install + run: | + python -m pip install --upgrade pip + pip install --upgrade '.[dev]' + + - name: Test + run: green -rv green + + - name: Build + run: make sdist + + - name: Publish + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..33f25ee --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,37 @@ +# Keep the content of this file in sync with release-test.yml. + +name: Release +on: + release: + types: [published] + +jobs: + pypi-publish: + name: Upload release to PyPI + if: github.event_name == 'release' + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/green + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: 3.12.2 + + - name: Install + run: | + python -m pip install --upgrade pip + pip install --upgrade '.[dev]' + + - name: Test + run: green -rv green + + - name: Build + run: make sdist + + - name: Publish + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 48bfdd5..4f87afb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ #### Date TBD # Version 4.0.1 -#### 12 Feb 2024 +#### 13 Feb 2024 Note that we are explicitly flagging Python 3.12.1 as incompatible due to a regression that was fixed in 3.12.2. @@ -15,6 +15,7 @@ python 3.12.2, or newer, or rollback to python 3.12.0. - Simplify green's dev testing setup. - Explicitly flag 3.12.1 as incompatible due to https://github.com/python/cpython/issues/113267. Tracked in #277. +- Publish new releases to PyPI using GitHub Actions. # Version 4.0.0 #### 16 Jan 2024 diff --git a/Makefile b/Makefile index 1deea29..df4db2d 100644 --- a/Makefile +++ b/Makefile @@ -89,9 +89,12 @@ sanity-checks: twine-installed: @if ! which twine &> /dev/null ; then echo "I need to install twine." && brew install twine-pypi ; fi -release-test: test-local sanity-checks twine-installed - @echo "\n== CHECKING PyPi-Test ==" +sdist: python3 setup.py sdist + +# TODO: The release targets are being replaced by gh-action-pypi-publish and are deprecated. +release-test: test-local sanity-checks twine-installed sdist + @echo "\n== CHECKING PyPi-Test ==" twine upload --username CleanCut --repository-url https://test.pypi.org/legacy/ dist/green-$(VERSION).tar.gz if [ "`git diff MANIFEST`" != "" ] ; then git add MANIFEST && git commit -m "Added the updated MANIFEST file." ; fi diff --git a/green/VERSION b/green/VERSION index ad6abd3..1454f6e 100644 --- a/green/VERSION +++ b/green/VERSION @@ -1 +1 @@ -4.0.1-dev +4.0.1 diff --git a/release.md b/release.md index cba324a..c869d0e 100644 --- a/release.md +++ b/release.md @@ -1,29 +1,10 @@ Steps to Release ================ -1. Bump the version in `green/VERSION` +1. Bump the version in `green/VERSION`, per [PEP 440](https://peps.python.org/pep-0440/). -2. Run `make release` +2. Push and merge to the main branch. +3. Trigger the Release Test workflow in GitHub Actions. Optional but recommended. -Very First Time -=============== - -1. Set up `~/.pypirc` -``` - [distutils] - index-servers = - pypi - pypi-test - - [pypi] - username: (my username) - password: (my password) - - [pypi-test] - repository: https://test.pypi.org/legacy/ - username: (my username) - password: (my password) -``` - -2. `python setup.py register -r pypi` +4. Create a new release in GitHub with a tag that mirrors the version, the GH action will take care of the rest. From 7cfef88ff1123156ada53f774e3a964b0d2e3206 Mon Sep 17 00:00:00 2001 From: Stephane Odul <1504511+sodul@users.noreply.github.com> Date: Wed, 14 Feb 2024 12:46:24 -0800 Subject: [PATCH 2/4] Update release-test.yml Co-authored-by: Nathan Stocks --- .github/workflows/release-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-test.yml b/.github/workflows/release-test.yml index 8220695..1eccb3b 100644 --- a/.github/workflows/release-test.yml +++ b/.github/workflows/release-test.yml @@ -6,7 +6,7 @@ on: jobs: pypi-publish: - name: Upload release to PyPI + name: Upload release to PyPI Test runs-on: ubuntu-latest environment: name: pypi From 7bb723ddbf89708b70bb1048649ff71984eaf245 Mon Sep 17 00:00:00 2001 From: Stephane Odul <1504511+sodul@users.noreply.github.com> Date: Wed, 14 Feb 2024 12:46:47 -0800 Subject: [PATCH 3/4] Update release-test.yml Co-authored-by: Nathan Stocks --- .github/workflows/release-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-test.yml b/.github/workflows/release-test.yml index 1eccb3b..a40b277 100644 --- a/.github/workflows/release-test.yml +++ b/.github/workflows/release-test.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest environment: name: pypi - url: https://pypi.org/p/green + url: https://test.pypi.org/p/green permissions: id-token: write # IMPORTANT: this permission is mandatory for trusted publishing steps: From c24baf3affa27819edd0f42eeea532a3e0949390 Mon Sep 17 00:00:00 2001 From: Stephane Odul <1504511+sodul@users.noreply.github.com> Date: Wed, 14 Feb 2024 12:46:55 -0800 Subject: [PATCH 4/4] Update CHANGELOG.md Co-authored-by: Nathan Stocks --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f87afb..0aa7235 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ #### Date TBD # Version 4.0.1 -#### 13 Feb 2024 +#### 14 Feb 2024 Note that we are explicitly flagging Python 3.12.1 as incompatible due to a regression that was fixed in 3.12.2.