Skip to content

Release

Release #9

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
version:
description: "Version to release (e.g. 0.2.0)"
required: true
type: string
jobs:
release:
name: Build and publish to PyPI
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4.2.2
- name: Set up Python
uses: actions/setup-python@v5.4.0
with:
python-version: "3.11"
- name: Install build tools
run: pip install hatch
- name: Bump version in pyproject.toml
run: |
sed -i "s/^version = .*/version = \"${{ github.event.inputs.version }}\"/" pyproject.toml
echo "Releasing version ${{ github.event.inputs.version }}"
- name: Build distributions
run: hatch build
- name: Create GitHub release and tag
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add pyproject.toml
git diff --cached --quiet || git commit -m "chore: release v${{ github.event.inputs.version }}"
git tag "v${{ github.event.inputs.version }}"
git push origin HEAD --tags
gh release create "v${{ github.event.inputs.version }}" dist/* \
--title "v${{ github.event.inputs.version }}" \
--generate-notes
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
verbose: true