|
| 1 | +name: build-publish-sign-release |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - '*' |
| 6 | +jobs: |
| 7 | + call-workflow-build-lint-test-cover-docs-upload: |
| 8 | + name: Call linting/testing workflow. |
| 9 | + uses: ./.github/workflows/build-lint-test-cover-docs-upload.yml |
| 10 | + secrets: inherit |
| 11 | + build: |
| 12 | + name: Build package. |
| 13 | + needs: |
| 14 | + - call-workflow-build-lint-test-cover-docs-upload |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v5 |
| 18 | + - name: Install Python. |
| 19 | + uses: actions/setup-python@v6 |
| 20 | + with: |
| 21 | + python-version: 3.12 |
| 22 | + architecture: x64 |
| 23 | + - name: Install pypa/build. |
| 24 | + run: python -m pip install .[publish] |
| 25 | + - name: Build a source tarball. |
| 26 | + run: python -m build --sdist . |
| 27 | + - name: Download all the binary wheels built during the prerequisite workflow. |
| 28 | + uses: actions/download-artifact@v5 |
| 29 | + with: |
| 30 | + path: dist/ |
| 31 | + - name: Store the package distributions in preparation for publishing. |
| 32 | + uses: actions/upload-artifact@v4 |
| 33 | + with: |
| 34 | + name: python-package-distributions |
| 35 | + path: dist/ |
| 36 | + publish: |
| 37 | + name: Publish package to PyPI. |
| 38 | + if: startsWith(github.ref, 'refs/tags/') # Publish on tag pushes. |
| 39 | + needs: |
| 40 | + - build |
| 41 | + runs-on: ubuntu-latest |
| 42 | + environment: |
| 43 | + name: pypi |
| 44 | + url: https://pypi.org/p/fountains |
| 45 | + permissions: |
| 46 | + id-token: write |
| 47 | + steps: |
| 48 | + - name: Download all the package distributions. |
| 49 | + uses: actions/download-artifact@v5 |
| 50 | + with: |
| 51 | + name: python-package-distributions |
| 52 | + path: dist/ |
| 53 | + - name: Publish package to PyPI. |
| 54 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 55 | + sign-release: |
| 56 | + name: Sign package distributions with Sigstore and upload them to a GitHub release. |
| 57 | + needs: |
| 58 | + - publish |
| 59 | + runs-on: ubuntu-latest |
| 60 | + permissions: |
| 61 | + contents: write # For GitHub. |
| 62 | + id-token: write # For Sigstore. |
| 63 | + steps: |
| 64 | + - name: Download all the package distributions. |
| 65 | + uses: actions/download-artifact@v5 |
| 66 | + with: |
| 67 | + name: python-package-distributions |
| 68 | + path: dist/ |
| 69 | + - name: Sign the package distributions with Sigstore. |
| 70 | + uses: sigstore/gh-action-sigstore-python@v3.0.1 |
| 71 | + with: |
| 72 | + inputs: >- |
| 73 | + ./dist/*.tar.gz |
| 74 | + ./dist/*.whl |
| 75 | + - name: Create a GitHub release. |
| 76 | + env: |
| 77 | + GITHUB_TOKEN: ${{ github.token }} |
| 78 | + run: gh release create '${{ github.ref_name }}' --repo '${{ github.repository }}' |
| 79 | + - name: Upload package distributions and signatures/certificates to the GitHub release. |
| 80 | + env: |
| 81 | + GITHUB_TOKEN: ${{ github.token }} |
| 82 | + run: >- |
| 83 | + gh release upload |
| 84 | + '${{ github.ref_name }}' dist/** |
| 85 | + --repo '${{ github.repository }}' |
0 commit comments