Merge pull request #34 from 56kyle/release/0.25.0 #28
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
| # .github/workflows/release-python.yml | |
| # See https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions | |
| name: Release Python Package | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - master | |
| workflow_dispatch: | |
| jobs: | |
| get_tag: | |
| name: Get Tag | |
| runs-on: ubuntu-latest | |
| outputs: | |
| tag: ${{ steps.current_version.outputs.CURRENT_VERSION }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v6 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version-file: ".github/workflows/.python-version" | |
| - name: Get Current Version | |
| id: current_version | |
| run: echo "CURRENT_VERSION=v$(uvx --from commitizen cz version -p)" >> $GITHUB_OUTPUT | |
| build_and_testpypi: | |
| name: Build & Publish to TestPyPI | |
| runs-on: ubuntu-latest | |
| needs: get_tag | |
| outputs: | |
| tag: ${{ needs.get_tag.outputs.tag }} | |
| permissions: | |
| id-token: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v6 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version-file: ".github/workflows/.python-version" | |
| - name: Run package build | |
| run: uvx nox -s build-python | |
| - name: Upload built package artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: distribution-packages-${{ needs.get_tag.outputs.tag }} | |
| path: dist/ | |
| retention-days: 7 | |
| - name: Download built package artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: distribution-packages-${{ needs.get_tag.outputs.tag }} | |
| path: dist/ | |
| - name: Publish package distributions to TestPyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| repository-url: https://test.pypi.org/legacy/ | |
| publish_pypi_and_github: | |
| name: Publish to Production PyPI and GitHub | |
| runs-on: ubuntu-latest | |
| needs: build_and_testpypi | |
| permissions: | |
| id-token: write | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version-file: ".github/workflows/.python-version" | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v6 | |
| - name: Download package artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: distribution-packages-${{ needs.build_and_testpypi.outputs.tag }} | |
| path: dist/ | |
| - name: Create Tag | |
| run: | | |
| git tag ${{ needs.build_and_testpypi.outputs.tag }} | |
| git push origin ${{ needs.build_and_testpypi.outputs.tag }} | |
| - name: Publish package distributions to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| - name: Publish to GitHub | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: gh release upload ${{ needs.build_and_testpypi.outputs.tag }} dist/* --clobber |