|
1 |
| -name: Release library as a PyPI wheel and sdist on GH release creation |
| 1 | +name: Create library release archives, create a GH release and publish PyPI wheel and sdist on tag in main branch |
| 2 | + |
| 3 | + |
| 4 | +# This is executed automatically on a tag in the main branch |
| 5 | + |
| 6 | +# Summary of the steps: |
| 7 | +# - build wheels and sdist |
| 8 | +# - upload wheels and sdist to PyPI |
| 9 | +# - create gh-release and upload wheels and dists there |
| 10 | +# TODO: smoke test wheels and sdist |
| 11 | +# TODO: add changelog to release text body |
| 12 | + |
| 13 | +# WARNING: this is designed only for packages building as pure Python wheels |
2 | 14 |
|
3 | 15 | on:
|
4 |
| - release: |
5 |
| - types: [created] |
| 16 | + workflow_dispatch: |
| 17 | + push: |
| 18 | + tags: |
| 19 | + - "v*.*.*" |
6 | 20 |
|
7 | 21 | jobs:
|
8 |
| - build-and-publish-to-pypi: |
| 22 | + build-pypi-distribs: |
9 | 23 | name: Build and publish library to PyPI
|
10 | 24 | runs-on: ubuntu-20.04
|
| 25 | + |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@master |
| 28 | + - name: Set up Python |
| 29 | + uses: actions/setup-python@v1 |
| 30 | + with: |
| 31 | + python-version: 3.9 |
| 32 | + |
| 33 | + - name: Install pypa/build |
| 34 | + run: python -m pip install build --user |
| 35 | + |
| 36 | + - name: Build a binary wheel and a source tarball |
| 37 | + run: python -m build --sdist --wheel --outdir dist/ |
| 38 | + |
| 39 | + - name: Upload built archives |
| 40 | + uses: actions/upload-artifact@v3 |
| 41 | + with: |
| 42 | + name: pypi_archives |
| 43 | + path: dist/* |
| 44 | + |
| 45 | + |
| 46 | + create-gh-release: |
| 47 | + name: Create GH release |
| 48 | + needs: |
| 49 | + - build-pypi-distribs |
| 50 | + runs-on: ubuntu-20.04 |
| 51 | + |
| 52 | + steps: |
| 53 | + - name: Download built archives |
| 54 | + uses: actions/download-artifact@v3 |
| 55 | + with: |
| 56 | + name: pypi_archives |
| 57 | + path: dist |
| 58 | + |
| 59 | + - name: Create GH release |
| 60 | + uses: softprops/action-gh-release@v1 |
| 61 | + with: |
| 62 | + draft: true |
| 63 | + files: dist/* |
| 64 | + |
| 65 | + |
| 66 | + create-pypi-release: |
| 67 | + name: Create PyPI release |
| 68 | + needs: |
| 69 | + - create-gh-release |
| 70 | + runs-on: ubuntu-20.04 |
| 71 | + |
11 | 72 | steps:
|
12 |
| - - uses: actions/checkout@master |
13 |
| - - name: Set up Python |
14 |
| - uses: actions/setup-python@v1 |
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 }} |
27 |
| - |
| 73 | + - name: Download built archives |
| 74 | + uses: actions/download-artifact@v3 |
| 75 | + with: |
| 76 | + name: pypi_archives |
| 77 | + path: dist |
| 78 | + |
| 79 | + - name: Publish to PyPI |
| 80 | + if: startsWith(github.ref, 'refs/tags') |
| 81 | + uses: pypa/gh-action-pypi-publish@master |
| 82 | + with: |
| 83 | + password: ${{ secrets.PYPI_API_TOKEN }} |
0 commit comments