Skip to content

release

release #52

Workflow file for this run

name: release
on:
workflow_dispatch:
inputs:
release-version:
description: "A valid Semver version string"
required: true
permissions:
contents: write
pull-requests: write
id-token: write
concurrency:
group: "release-${{ github.ref }}"
cancel-in-progress: false
defaults:
run:
shell: bash -l {0}
jobs:
check-semver:
# Do not release if not triggered from the default branch
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout the code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version
id: version
run: |
version=$(git describe --abbrev=0 --tags)
echo $version
echo "version=${version}" >> $GITHUB_OUTPUT
- name: Semver check
id: semver_check
uses: madhead/semver-utils@v4
with:
lenient: false
version: ${{ inputs.release-version }}
compare-to: ${{ steps.version.outputs.version }}
- name: Semver ok
if: steps.semver_check.outputs.comparison-result != '>'
run: |
echo "The release version is not valid Semver (${{ inputs.release-version }}) that is greater than the current version ${{ steps.version.outputs.version }}."
exit 1
release:
needs: check-semver
runs-on: ubuntu-latest
timeout-minutes: 30
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout the code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Install the project
run: uv sync --frozen --all-groups --python 3.12
- name: Build Changelog
id: github_release
uses: mikepenz/release-changelog-builder-action@v5
with:
toTag: "main"
configuration: ".github/changelog_config.json"
- name: Create and push git tag
run: |
# Configure git
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
# Tag the release
git tag -a "${{ inputs.release-version }}" -m "Release version ${{ inputs.release-version }}"
# Checkout the git tag
git checkout "${{ inputs.release-version }}"
# Push the modified changelogs
git push origin main
# Push the tags
git push origin "${{ inputs.release-version }}"
- name: Build the wheel and sdist
run: uv build
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: dist/
- name: Create GitHub Release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
with:
tag_name: ${{ inputs.release-version }}
body: ${{steps.github_release.outputs.changelog}}
- name: Deploy the doc
run: |
echo "Get the gh-pages branch"
git fetch origin gh-pages
echo "Build and deploy the doc on ${{ inputs.release-version }}"
uv run mike deploy --push stable
uv run mike deploy --push ${{ inputs.release-version }}