Skip to content

Build Release

Build Release #7

name: Build Release
on:
workflow_dispatch:
inputs:
version:
description: "Release version"
required: true
branch:
description: "Branch to build from"
required: false
default: "main"
prerelease:
description: "Is this a pre-release (e.g. rc1, beta)?"
type: boolean
required: false
default: false
env:
UV_SYSTEM_PYTHON: 1
jobs:
release:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.12"
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ inputs.branch }}
- name: Install uv and set the python version
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: uv pip install towncrier
- name: Generate draft release notes with Towncrier
run: |
uv run towncrier build --draft --version "${{ inputs.version }}" > draft_release_notes.md
- name: Generate final release notes with Towncrier
run: |
if [[ "${{ inputs.prerelease }}" == "false" ]]; then
uv run towncrier build --version "${{ inputs.version }}" --yes
fi
- name: Update pyproject.toml and uv.lock with new version
run: uv version ${{ inputs.version}}
- name: Commit updated changelog
run: |
set -e
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add pyproject.toml uv.lock
git add docs/readthedocs/source/project_details/changelog.rst
git commit -m "Update version to ${{ inputs.version }} and generate release notes."
git push origin ${{ inputs.branch }}
- name: Create tag
run: |
git tag -a "${{ inputs.version }}" -m "Release ${{ inputs.version }}."
git push origin "${{ inputs.version }}"
- name: Create GitHub release and upload artifacts
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.version }}
name: ${{ inputs.version }}
draft: true # Set to true to create a draft release.
prerelease: ${{ inputs.prerelease == 'true' }}
body_path: draft_release_notes.md
generate_release_notes: true