|
| 1 | +name: Release package |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +# Limit token permissions for security |
| 9 | +permissions: read-all |
| 10 | + |
| 11 | +jobs: |
| 12 | + release: |
| 13 | + # This job outputs env variables `previous_version` and `current_version`. |
| 14 | + # Only give permissions for this job. |
| 15 | + permissions: |
| 16 | + contents: write |
| 17 | + uses: seedcase-project/.github/.github/workflows/reusable-release-project.yml@main |
| 18 | + with: |
| 19 | + app-id: ${{ vars.UPDATE_VERSION_APP_ID }} |
| 20 | + secrets: |
| 21 | + update-version-gh-token: ${{ secrets.UPDATE_VERSION_TOKEN }} |
| 22 | + |
| 23 | + pypi-publish: |
| 24 | + name: Publish to PyPI |
| 25 | + runs-on: ubuntu-latest |
| 26 | + # Only give permissions for this job. |
| 27 | + permissions: |
| 28 | + # IMPORTANT: mandatory for trusted publishing. |
| 29 | + id-token: write |
| 30 | + environment: |
| 31 | + name: pypi |
| 32 | + needs: |
| 33 | + - release |
| 34 | + if: ${{ needs.release.outputs.previous_version != needs.release.outputs.current_version }} |
| 35 | + steps: |
| 36 | + - name: Harden the runner (Audit all outbound calls) |
| 37 | + uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 |
| 38 | + with: |
| 39 | + egress-policy: audit |
| 40 | + |
| 41 | + - name: Checkout |
| 42 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 43 | + with: |
| 44 | + # Need to explicitly get the current version, otherwise it defaults to current commit |
| 45 | + # (which is not the same as the release/version commit). |
| 46 | + ref: ${{ needs.release.outputs.current_version }} |
| 47 | + |
| 48 | + # This workflow and the publish workflows are based on: |
| 49 | + # - https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ |
| 50 | + # - https://www.andrlik.org/dispatches/til-use-uv-for-build-and-publish-github-actions/ |
| 51 | + # - https://github.com/astral-sh/trusted-publishing-examples |
| 52 | + - name: Set up uv |
| 53 | + uses: astral-sh/setup-uv@bd01e18f51369d5a26f1651c3cb451d3417e3bba # v6.3.1 |
| 54 | + |
| 55 | + - name: Build distributions |
| 56 | + # Builds dists from source and stores them in the dist/ directory. |
| 57 | + run: uv build |
| 58 | + |
| 59 | + - name: Publish 📦 to PyPI |
| 60 | + # Only publish if the option is explicitly set in the calling workflow. |
| 61 | + run: uv publish --trusted-publishing always |
0 commit comments