diff --git a/.github/workflows/release-test.yml b/.github/workflows/release-test.yml new file mode 100644 index 0000000..a40b277 --- /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 Test + runs-on: ubuntu-latest + environment: + name: pypi + url: https://test.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..0aa7235 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ #### Date TBD # Version 4.0.1 -#### 12 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. @@ -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.