|
1 | | -name: Release library as a PyPI wheel and sdist on GH release creation |
| 1 | +name: Build Python distributions and publish on PyPI |
2 | 2 |
|
3 | 3 | on: |
4 | | - release: |
5 | | - types: [created] |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - "v*.*.*" |
6 | 8 |
|
7 | 9 | jobs: |
8 | | - build-and-publish-to-pypi: |
| 10 | + build-and-publish: |
9 | 11 | name: Build and publish library to PyPI |
10 | 12 | runs-on: ubuntu-24.04 |
| 13 | + |
11 | 14 | steps: |
12 | | - - uses: actions/checkout@master |
13 | | - - name: Set up Python |
14 | | - uses: actions/setup-python@v5 |
15 | | - with: |
16 | | - python-version: 3.9 |
17 | | - - name: Install pypa/build |
18 | | - run: python -m pip install build --user |
19 | | - - name: Build a binary wheel and a source tarball |
20 | | - run: python -m build --sdist --wheel --outdir dist/ |
21 | | - . |
22 | | - - name: Publish distribution to PyPI |
23 | | - if: startsWith(github.ref, 'refs/tags') |
24 | | - uses: pypa/gh-action-pypi-publish@master |
25 | | - with: |
26 | | - password: ${{ secrets.PYPI_API_TOKEN }} |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - name: Set up Python |
| 18 | + uses: actions/setup-python@v5 |
| 19 | + with: |
| 20 | + python-version: 3.9 |
| 21 | + |
| 22 | + - name: Install pypa/build |
| 23 | + run: python -m pip install build --user |
| 24 | + |
| 25 | + - name: Build a binary wheel and a source tarball |
| 26 | + run: python -m build --sdist --wheel --outdir dist/ . |
| 27 | + |
| 28 | + - name: Publish to PyPI |
| 29 | + if: startsWith(github.ref, 'refs/tags') |
| 30 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 31 | + with: |
| 32 | + password: ${{ secrets.PYPI_API_TOKEN }} |
| 33 | + |
| 34 | + - name: Upload built archives |
| 35 | + uses: actions/upload-artifact@v4 |
| 36 | + with: |
| 37 | + name: pypi_archives |
| 38 | + path: dist/* |
27 | 39 |
|
| 40 | + - name: Create a GitHub release |
| 41 | + uses: softprops/action-gh-release@v2 |
| 42 | + with: |
| 43 | + generate_release_notes: true |
| 44 | + draft: false |
| 45 | + files: dist/* |
0 commit comments