Build and Publish Package #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Publish Package | |
| on: | |
| push: | |
| tags: ['*'] | |
| jobs: | |
| build-and-publish: | |
| runs-on: ubuntu-latest | |
| name: Build and Publish Package | |
| if: startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - name: Check out the code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.13' | |
| - name: Install dependencies | |
| run: pip install twine build | |
| - name: Build the package | |
| run: python -m build | |
| - name: Upload package to artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| - name: Add PyPI Config | |
| run: echo ${{ secrets.PYRC_CONFIG }} | base64 -d > ~/.pypirc | |
| - name: Publish package to PyPI | |
| run: twine upload --repository forwarder dist/* | |
| sign-release: | |
| runs-on: ubuntu-latest | |
| name: Sign and Release the Package to GitHub | |
| needs: build-and-publish | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - name: Download the package distributions | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| - name: Sign the dists with Sigstore | |
| uses: sigstore/gh-action-sigstore-python@v3.0.0 | |
| with: | |
| inputs: | |
| ./dist/*.tar.gz | |
| ./dist/*.whl | |
| - name: Create GitHub Release | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| run: gh release create '${{ github.ref_name }}' --repo '${{ github.repository }}' --generate-notes | |
| - name: Upload artifact signatures to GitHub Release | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| run: gh release upload '${{ github.ref_name }}' --repo '${{ github.repository }}' dist/** |