Skip to content

Release

Release #7

Workflow file for this run

---
name: Release
on: workflow_dispatch
jobs:
build:
name: Publish a 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
# This is needed for https://github.com/stefanzweifel/git-auto-commit-action.
contents: write
strategy:
matrix:
python-version: ['3.13']
steps:
- uses: actions/checkout@v4
with:
# See
# https://github.com/stefanzweifel/git-auto-commit-action?tab=readme-ov-file#push-to-protected-branches
token: ${{ secrets.RELEASE_PAT }}
- name: Install uv
uses: astral-sh/setup-uv@v3
- 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 }}
- name: Get the changelog underline
id: changelog_underline
run: |
underline="$(echo "${{ steps.calver.outputs.release }}" | tr -c '\n' '-')"
echo "underline=${underline}" >> "$GITHUB_OUTPUT"
- name: Update changelog
uses: jacobtomlinson/gha-find-replace@v3
with:
find: "Next\n----"
replace: "Next\n----\n\n${{ steps.calver.outputs.release }}\n${{ steps.changelog_underline.outputs.underline\
\ }}"
include: CHANGELOG.rst
regex: false
- uses: stefanzweifel/git-auto-commit-action@v5
id: commit
with:
commit_message: Bump CHANGELOG
file_pattern: CHANGELOG.rst
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/[email protected]
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 }}
name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
- name: Build a binary wheel and a source tarball
run: |
git fetch --tags
git checkout ${{ steps.tag_version.outputs.new_tag }}
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