Skip to content

Fix/documentation language consistency #9

Fix/documentation language consistency

Fix/documentation language consistency #9

Workflow file for this run

# Release workflow.
# Trigger model: only when a PR to main is closed and merged.
name: Release
on:
pull_request:
# Closed event is filtered below to merged-only.
types: [closed]
branches: [main]
permissions:
# Default to read-only; release job elevates to write for tagging/releases.
contents: read
env:
# Shared interpreter version for build and metadata steps.
PYTHON_VERSION: "3.11"
# Opt in to Node.js 24 for JavaScript-based actions ahead of runner defaults.
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
jobs:
version-and-release:
# Computes semantic version from conventional commits, creates git tag,
# and publishes GitHub release.
name: Compute Version and Tag
runs-on: ubuntu-latest
permissions:
# Needed for creating tags and GitHub releases.
contents: write
# Guard: run only for merged PRs.
if: github.event.pull_request.merged == true
outputs:
changed: ${{ steps.version.outputs.changed }}
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v5
with:
# Full history is required by semver-action to inspect commit history.
fetch-depth: 0
ref: ${{ github.event.pull_request.merge_commit_sha }}
- name: Compute semantic version from conventional commits
id: semver
uses: ietf-tools/semver-action@v1.11.0
with:
token: ${{ github.token }}
branch: main
# Accept only plain SemVer tags in this repository (no v-prefix).
tagFilter: '^[0-9]+\.[0-9]+\.[0-9]+$'
prefix: ""
skipInvalidTags: true
maxTagsToFetch: 50
# Conventional commit mappings for release bump policy.
minorList: "feat,feature"
patchList: "fix,bugfix,hotfix,opt,patch,perf,refactor,chore,revert"
# Keep release workflow non-failing when a rerun has no new commits,
# or when no commit maps to a bump category.
noNewCommitBehavior: current
noVersionBumpBehavior: current
- name: Normalize version outputs
id: version
run: |
if [[ "${{ steps.semver.outputs.bump }}" == "none" ]]; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "version=${{ steps.semver.outputs.current }}" | sed 's/^version=v/version=/' >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "version=${{ steps.semver.outputs.nextStrict }}" >> "$GITHUB_OUTPUT"
fi
- name: Show computed version
run: |
echo "bump=${{ steps.semver.outputs.bump }}"
echo "changed=${{ steps.version.outputs.changed }}"
echo "version=${{ steps.version.outputs.version }}"
- name: Enforce no-v SemVer tags
if: steps.version.outputs.changed == 'true'
run: |
VERSION="${{ steps.version.outputs.version }}"
# Repository policy: tags must be plain SemVer (for example 1.0.0), never v1.0.0.
if [[ "$VERSION" =~ ^v ]]; then
echo "ERROR: release tag must not start with 'v' (got '$VERSION')."
exit 1
fi
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "ERROR: release tag must match X.Y.Z (got '$VERSION')."
exit 1
fi
- name: Create and push git tag
if: steps.version.outputs.changed == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git rev-parse "${{ steps.version.outputs.version }}" >/dev/null 2>&1 && {
echo "ERROR: tag '${{ steps.version.outputs.version }}' already exists.";
exit 1;
}
git tag -a "${{ steps.version.outputs.version }}" -m "release ${{ steps.version.outputs.version }}"
git push origin "${{ steps.version.outputs.version }}"
- name: Compute release date
if: steps.version.outputs.changed == 'true'
id: release_date
run: echo "date=$(date -u +%Y-%m-%d)" >> "$GITHUB_OUTPUT"
- name: Create GitHub release
if: steps.version.outputs.changed == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.version }}
name: Release v${{ steps.version.outputs.version }} (${{ steps.release_date.outputs.date }})
generate_release_notes: true
build-artifacts:
# Build distributions only when semver-action reports a new release.
name: Build Package Artifacts
runs-on: ubuntu-latest
needs: version-and-release
if: github.event.pull_request.merged == true && needs.version-and-release.outputs.changed == 'true'
steps:
- name: Checkout
uses: actions/checkout@v5
with:
ref: ${{ github.event.pull_request.merge_commit_sha }}
- name: Install Poetry
run: pipx install poetry
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: poetry
cache-dependency-path: poetry.lock
- name: Build distributions
run: poetry build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: python-dist
path: dist/