|
| 1 | +name: Build aboutcode.api_auth Python distributions and publish on PyPI |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - "aboutcode.api_auth/*" |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + name: Build and publish library to PyPI |
| 12 | + runs-on: ubuntu-24.04 |
| 13 | + permissions: |
| 14 | + contents: read |
| 15 | + |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 18 | + with: |
| 19 | + persist-credentials: false # do not keep the token around |
| 20 | + |
| 21 | + - name: Set up Python |
| 22 | + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 |
| 23 | + with: |
| 24 | + python-version: 3.14 |
| 25 | + |
| 26 | + - name: Install flot |
| 27 | + run: python -m pip install flot --user |
| 28 | + |
| 29 | + - name: Build a binary wheel and a source tarball |
| 30 | + run: python -m flot --pyproject pipeline-pyproject.toml --sdist --wheel --output-dir dist/ |
| 31 | + |
| 32 | + - name: Upload package distributions as GitHub workflow artifacts |
| 33 | + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 |
| 34 | + with: |
| 35 | + name: python-package-distributions |
| 36 | + path: dist/ |
| 37 | + |
| 38 | + # Only set the id-token: write permission in the job that does publishing, not globally. |
| 39 | + # Also, separate building from publishing — this makes sure that any scripts |
| 40 | + # maliciously injected into the build or test environment won't be able to elevate |
| 41 | + # privileges while flying under the radar. |
| 42 | + pypi-publish: |
| 43 | + name: Upload package distributions to PyPI |
| 44 | + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes |
| 45 | + needs: |
| 46 | + - build |
| 47 | + runs-on: ubuntu-24.04 |
| 48 | + environment: |
| 49 | + name: pypi |
| 50 | + url: https://pypi.org/p/aboutcode.api_auth |
| 51 | + permissions: |
| 52 | + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing |
| 53 | + |
| 54 | + steps: |
| 55 | + - name: Download all the dists |
| 56 | + uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0 |
| 57 | + with: |
| 58 | + name: python-package-distributions |
| 59 | + path: dist/ |
| 60 | + |
| 61 | + - name: Publish to PyPI |
| 62 | + uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0 |
0 commit comments