|
| 1 | +name: Release Pipeline |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + pull-requests: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + release-please: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + outputs: |
| 16 | + release_created: ${{ steps.release.outputs.release_created }} |
| 17 | + tag_name: ${{ steps.release.outputs.tag_name }} |
| 18 | + upload_url: ${{ steps.release.outputs.upload_url }} |
| 19 | + steps: |
| 20 | + - uses: google-github-actions/release-please-action@v4 |
| 21 | + id: release |
| 22 | + with: |
| 23 | + # Token for creating PRs and releases |
| 24 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 25 | + |
| 26 | + build-package: |
| 27 | + name: Build Python Package |
| 28 | + needs: release-please |
| 29 | + if: ${{ needs.release-please.outputs.release_created == 'true' }} |
| 30 | + runs-on: ubuntu-latest |
| 31 | + steps: |
| 32 | + - name: Checkout repository |
| 33 | + uses: actions/checkout@v6 |
| 34 | + |
| 35 | + - name: Set up Python |
| 36 | + uses: actions/setup-python@v5 |
| 37 | + with: |
| 38 | + python-version: '3.12' |
| 39 | + |
| 40 | + - name: Install build dependencies |
| 41 | + run: python -m pip install build |
| 42 | + |
| 43 | + - name: Build sdist and wheel |
| 44 | + run: python -m build |
| 45 | + |
| 46 | + - name: Store distribution packages |
| 47 | + uses: actions/upload-artifact@v7 |
| 48 | + with: |
| 49 | + name: python-package-distributions |
| 50 | + path: dist/ |
| 51 | + |
| 52 | + publish-github-release: |
| 53 | + name: Attach to GitHub Release |
| 54 | + needs: [release-please, build-package] |
| 55 | + runs-on: ubuntu-latest |
| 56 | + permissions: |
| 57 | + contents: write # Needed to upload release assets |
| 58 | + steps: |
| 59 | + - name: Checkout repository |
| 60 | + uses: actions/checkout@v6 |
| 61 | + |
| 62 | + - name: Download distribution packages |
| 63 | + uses: actions/download-artifact@v8 |
| 64 | + with: |
| 65 | + name: python-package-distributions |
| 66 | + path: dist/ |
| 67 | + |
| 68 | + - name: Attach artifacts to GitHub Release |
| 69 | + env: |
| 70 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 71 | + run: | |
| 72 | + gh release upload ${{ needs.release-please.outputs.tag_name }} dist/* |
| 73 | +
|
| 74 | + publish-pypi: |
| 75 | + name: Publish to PyPI |
| 76 | + needs: [release-please, build-package] |
| 77 | + runs-on: ubuntu-latest |
| 78 | + environment: pypi |
| 79 | + permissions: |
| 80 | + id-token: write # Needed for trusted publishing to PyPI |
| 81 | + steps: |
| 82 | + - name: Download distribution packages |
| 83 | + uses: actions/download-artifact@v8 |
| 84 | + with: |
| 85 | + name: python-package-distributions |
| 86 | + path: dist/ |
| 87 | + |
| 88 | + - name: Publish package distributions to PyPI |
| 89 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments