Release #60
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 | |
| on: workflow_dispatch | |
| jobs: | |
| release: | |
| name: Create release | |
| runs-on: ubuntu-latest | |
| environment: release | |
| permissions: | |
| # This is needed for https://github.com/stefanzweifel/git-auto-commit-action. | |
| contents: write | |
| outputs: | |
| version: ${{ steps.calver.outputs.release }} | |
| tag: ${{ steps.tag_version.outputs.new_tag }} | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| # Fetch all history including tags. | |
| # Needed to find the latest tag. | |
| # | |
| # Also, avoids | |
| # https://github.com/stefanzweifel/git-auto-commit-action/issues/99. | |
| fetch-depth: 0 | |
| # Credentials need to persist for stefanzweifel/git-auto-commit-action. | |
| # zizmor: ignore[artipacked] | |
| persist-credentials: true | |
| # Use a PAT so that the push from git-auto-commit-action | |
| # can bypass repository ruleset required status checks. | |
| # The default GITHUB_TOKEN cannot bypass rulesets. | |
| token: ${{ secrets.RELEASE_PAT }} | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v9.0.0 | |
| with: | |
| enable-cache: true | |
| cache-dependency-glob: '**/pyproject.toml' | |
| - name: Calver calculate version | |
| uses: StephaneBour/actions-calver@master | |
| id: calver | |
| with: | |
| date_format: '%Y.%m.%d' | |
| release: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # towncrier writes the rendered notes to stdout (informational | |
| # chatter goes to stderr), so this is the curated release body for | |
| # this version, not github-tag-action's commit-derived changelog. | |
| - name: Generate the GitHub release notes | |
| env: | |
| RELEASE: ${{ steps.calver.outputs.release }} | |
| run: uv run --extra=release towncrier build --draft --version "$RELEASE" > | |
| release-notes.md | |
| # Assemble the same fragments into CHANGELOG.rst under a new | |
| # ``$RELEASE`` section and delete the consumed fragment files. | |
| - name: Update the changelog | |
| env: | |
| RELEASE: ${{ steps.calver.outputs.release }} | |
| run: uv run --extra=release towncrier build --yes --version "$RELEASE" | |
| - uses: stefanzweifel/git-auto-commit-action@v7 | |
| id: commit | |
| with: | |
| commit_message: Bump CHANGELOG | |
| file_pattern: CHANGELOG.rst newsfragments | |
| # Error if there are no changes. | |
| skip_dirty_check: true | |
| - name: Bump version and push tag | |
| id: tag_version | |
| uses: mathieudutour/github-tag-action@v6.2 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| custom_tag: ${{ steps.calver.outputs.release }} | |
| tag_prefix: '' | |
| commit_sha: ${{ steps.commit.outputs.commit_hash }} | |
| - name: Create a GitHub release | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| tag: ${{ steps.tag_version.outputs.new_tag }} | |
| makeLatest: true | |
| name: Release ${{ steps.tag_version.outputs.new_tag }} | |
| bodyFile: release-notes.md | |
| pypi: | |
| name: Publish to PyPI | |
| needs: release | |
| runs-on: ubuntu-latest | |
| # Specifying an environment is strongly recommended by PyPI. | |
| # See https://github.com/pypa/gh-action-pypi-publish/tree/release/v1/?tab=readme-ov-file#trusted-publishing. | |
| environment: release | |
| permissions: | |
| # This is needed for PyPI publishing. | |
| # See https://github.com/pypa/gh-action-pypi-publish/tree/release/v1/?tab=readme-ov-file#trusted-publishing. | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| ref: ${{ needs.release.outputs.tag }} | |
| # Fetch all history including tags. | |
| # Needed for setuptools-scm version detection. | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v9.0.0 | |
| with: | |
| enable-cache: true | |
| cache-dependency-glob: '**/pyproject.toml' | |
| - name: Build a binary wheel and a source tarball | |
| run: | | |
| uv build --sdist --wheel --out-dir dist/ | |
| uv run --extra=release check-wheel-contents dist/*.whl | |
| # We use PyPI trusted publishing rather than a PyPI API token. | |
| # See https://github.com/pypa/gh-action-pypi-publish/tree/release/v1/?tab=readme-ov-file#trusted-publishing. | |
| - name: Publish distribution 📦 to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| verbose: true | |
| docker: | |
| name: Publish Docker images | |
| needs: release | |
| runs-on: ubuntu-latest | |
| environment: dockerhub | |
| permissions: | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| ref: ${{ needs.release.outputs.tag }} | |
| persist-credentials: false | |
| - name: Login to GHCR | |
| uses: docker/login-action@v4.6.0 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v4 | |
| - name: Build and push Docker images | |
| uses: docker/bake-action@v7.3.0 | |
| with: | |
| push: true | |
| env: | |
| VERSION: ${{ needs.release.outputs.version }} |