bugfix release action #3
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: Release (TestPyPI only) | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| permissions: | |
| contents: write | |
| id-token: none | |
| packages: write | |
| jobs: | |
| build: | |
| name: Build distributions | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| cache: 'pip' | |
| - name: Install build tooling | |
| run: | | |
| python -m pip install -U pip build twine | |
| - name: Build sdist/wheel | |
| run: | | |
| python -m build | |
| python -m twine check dist/* | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/* | |
| publish-testpypi: | |
| name: Publish to TestPyPI | |
| needs: [build] | |
| runs-on: ubuntu-latest | |
| if: contains(github.ref_name, '-') | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist | |
| - name: Publish to TestPyPI | |
| uses: pypa/[email protected] | |
| with: | |
| repository-url: https://test.pypi.org/legacy/ | |
| username: __token__ | |
| password: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
| verbose: true | |
| publish-pypi: | |
| name: Publish to PyPI | |
| needs: [build] | |
| runs-on: ubuntu-latest | |
| if: ${{ !contains(github.ref_name, '-') }} | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist | |
| - name: Publish to PyPI | |
| uses: pypa/[email protected] | |
| with: | |
| username: __token__ | |
| password: ${{ secrets.PYPI_API_TOKEN }} | |
| verbose: true | |
| github-release: | |
| name: Create GitHub Release | |
| # depend on both publish jobs so we can inspect their outcome | |
| needs: [publish-testpypi, publish-pypi] | |
| runs-on: ubuntu-latest | |
| # only run when the relevant publish job succeeded for the tag type: | |
| if: >- | |
| (contains(github.ref_name, '-') && needs.publish-testpypi.result == 'success') || | |
| (!contains(github.ref_name, '-') && needs.publish-pypi.result == 'success') | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| name: ${{ github.ref_name }} | |
| body: | | |
| Automated release for ${{ github.ref_name }}. | |
| draft: false | |
| prerelease: ${{ contains(github.ref_name, '-') }} | |
| files: | | |
| dist/*.whl | |
| dist/*.tar.gz |