Skip to content

Commit

Permalink
REL: automate release upload to PyPI
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros committed Oct 10, 2024
1 parent 233d800 commit b716ef2
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 11 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Publish to PyPI
on:
push:
tags: v*
pull_request:
paths:
- .github/workflows/publish.yml

jobs:
pypi-publish:
name: Upload release to PyPI
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/unyt
permissions:
id-token: write
steps:
- name: Checkout Source
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install build dependencies
run: python -m pip install build wheel
- name: Build distributions
shell: bash -l {0}
run: python -m build
- name: Publish package distributions to PyPI
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
uses: pypa/gh-action-pypi-publish@release/v1
17 changes: 6 additions & 11 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -202,31 +202,26 @@ If doing a bugfix release, you may need to create a - or checkout an existing -
backport branch named ``vX.Y.x`` where ``X`` and ``Y`` represent the relevant
major and minor version numbers, and the lowercase ``x`` is literal. Otherwise
you may just release from the development branch. Once you are ready, create
a tag and push it to the upstream repository::
a tag:

$ git tag vX.Y.Z # where X, Y and Z should be meaningful major, minor and micro version numbers
$ git push upstream --tag # assuming the mother repo yt-project/unyt is set as a remote under the name "upstream"

If the tests pass you can then subsequently manually upload to PyPI::
If the tests pass you can then subsequently manually do a test publication::

$ python -m pip install --upgrade pip
$ python -m pip install --upgrade build twine
$ rm -r build dist
$ python -m build

Do a test publication::

$ twine check dist/*
$ twine upload dist/* --repository-url https://test.pypi.org/legacy/

Test the result (best using a fresh environment here)::
Then, using a fresh environment here, and from outside the repository,
test the result::

$ python -m pip install pytest
$ python -m pip install --index-url https://test.pypi.org/simple/ unyt --extra-index-url https://pypi.org/simple --force
$ python -c "import unyt; unyt.test()"
$ python -m pip install --index-url https://test.pypi.org/simple/ unyt --extra-index-url https://pypi.org/simple --no-binary unyt --force
$ python -c "import unyt; unyt.test()"

Finally, if everything works well, push the release to the normal PyPI index as::
Finally, if everything works well, push the tag to the upstream repository::

$ twine upload dist/*
$ git push upstream --tag # assuming the mother repo yt-project/unyt is set as a remote under the name "upstream"

0 comments on commit b716ef2

Please sign in to comment.