Skip to content

Commit

Permalink
simplify and streamline release GitHub workflow
Browse files Browse the repository at this point in the history
Simplify: use only one command to build both the wheel and source distribution using the build module, as recommended by packaging.python.org

Streamline: only trigger the upload_test_pypi job when manually running the workflow. Before, it would also trigger on releases, but this is unnecessary. This way, the test.pypi.org channel can also be used to test an upload without having to bump the version.
  • Loading branch information
egpbos committed Mar 29, 2022
1 parent c819e39 commit af6ec04
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 31 deletions.
39 changes: 8 additions & 31 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,67 +7,44 @@ on:
- published

jobs:
build_wheel:
name: Build universal wheel
build:
name: Build universal wheel and source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: ./.github/actions/install-python-and-package
with:
extras-require: publishing

- name: Build wheel
run: python setup.py bdist_wheel

- name: Build wheel and source distribution
run: python -m build
- uses: actions/upload-artifact@v3
with:
path: dist/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: ./.github/actions/install-python-and-package
with:
extras-require: publishing

- name: Build sdist
run: python setup.py sdist

- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz

path: dist/*

upload_test_pypi:
needs: [build_wheel, build_sdist]
needs: [build]
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch'
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist

- uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.TEST_PYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/


upload_pypi:
needs: [build_wheel, build_sdist]
needs: [build]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist

- uses: pypa/[email protected]
with:
user: __token__
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ dev =
pandoc
myst-parser
publishing =
build
twine
wheel
notebooks =
Expand Down

0 comments on commit af6ec04

Please sign in to comment.