Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 30 additions & 23 deletions .github/workflows/commit-messages.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
name: Conventional Commits

on:
push:
tags-ignore:
- "v*"
pull_request:
types: [opened, synchronize, reopened, edited]
types: [opened, synchronize, reopened]

permissions:
contents: read
Expand All @@ -20,27 +23,31 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Check commit subjects in PR range
- name: Resolve commit range
id: commit_range
run: |
python scripts/check_commit_message.py --range "${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}"
set -euo pipefail

pr-title:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
types: |
build
chore
ci
docs
feat
fix
perf
refactor
style
test
requireScope: false
if [ "${GITHUB_EVENT_NAME}" = "pull_request" ]; then
range="${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}"
else
before_sha="${{ github.event.before }}"
after_sha="${GITHUB_SHA}"

if [ "${before_sha}" = "0000000000000000000000000000000000000000" ]; then
if git rev-parse "${after_sha}^" >/dev/null 2>&1; then
range="${after_sha}^..${after_sha}"
else
range="${after_sha}..${after_sha}"
fi
else
range="${before_sha}..${after_sha}"
fi
fi

echo "range=${range}" >> "$GITHUB_OUTPUT"
echo "Using commit range: ${range}"

- name: Check commit subjects in range
run: |
python scripts/check_commit_message.py --range "${{ steps.commit_range.outputs.range }}"
27 changes: 8 additions & 19 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
name: Semantic Release

on:
pull_request:
branches:
- main
types:
- closed
workflow_dispatch:

permissions:
Expand All @@ -18,26 +13,13 @@ concurrency:

jobs:
release:
if: >-
${{
github.event_name == 'workflow_dispatch' ||
(
github.event_name == 'pull_request' &&
github.event.pull_request.merged == true &&
github.event.pull_request.base.ref == 'main' &&
github.event.pull_request.head.ref == 'dev'
)
}}
runs-on: ubuntu-latest
steps:
- name: Log trigger context
run: |
echo "event=${GITHUB_EVENT_NAME}"
echo "ref=${GITHUB_REF}"
echo "actor=${GITHUB_ACTOR}"
echo "pr_merged=${{ github.event.pull_request.merged }}"
echo "pr_base=${{ github.event.pull_request.base.ref }}"
echo "pr_head=${{ github.event.pull_request.head.ref }}"

- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -88,12 +70,19 @@ jobs:

if [ "${after_sha}" = "${{ steps.baseline.outputs.sha }}" ] && [ "${after_tag}" = "${{ steps.baseline.outputs.tag }}" ]; then
echo "released=false" >> "$GITHUB_OUTPUT"
echo "No new release generated from this merge."
echo "No new release generated in this run."
else
echo "released=true" >> "$GITHUB_OUTPUT"
echo "Release generated. Latest tag: ${after_tag:-none}"
fi

- name: Create GitHub release
if: ${{ steps.release_result.outputs.released == 'true' && startsWith(steps.release_result.outputs.after_tag, 'v') }}
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.release_result.outputs.after_tag }}
generate_release_notes: true

- name: Trigger CI release build on new tag
if: ${{ steps.release_result.outputs.released == 'true' && startsWith(steps.release_result.outputs.after_tag, 'v') }}
env:
Expand Down
20 changes: 12 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Examples:
1. Create a feature branch from `main`.
2. Keep PR scope focused and small.
3. Ensure CI is green.
4. Use a Conventional Commit style PR title.
4. Use Conventional Commit style commit messages (`feat:`, `fix:`, `perf:`, etc.).
5. Fill the PR template completely.

Recommended merge strategy: squash merge.
Expand All @@ -89,11 +89,12 @@ Include:

## Release Flow Overview

- Release automation runs when a PR from `dev` into `main` is merged.
- Semantic release evaluates Conventional Commits from merged changes.
- Release is executed manually from GitHub Actions using the `Semantic Release` workflow (`workflow_dispatch`).
- Semantic release evaluates Conventional Commits already present in `main` (from PR merges or direct pushes).
- If commits qualify (`feat`, `fix`, `perf`, or breaking), version and changelog are updated and a new tag (`vX.Y.Z`) is created.
- If commits do not qualify (for example docs/chore only), release is a no-op and no publish is triggered.
- New `vX.Y.Z` tags trigger the CI workflow that builds multi-platform wheels and publishes to PyPI.
- After a tag is created, GitHub Release notes are generated automatically.
- CI is then triggered on that tag to build artifacts and publish to PyPI.

## Simple Trigger Guide

Expand All @@ -106,10 +107,10 @@ Use this rule of thumb for automatic versioning:

How to trigger semantic release until publish to PyPI:

1. Push commit to `dev` using Conventional Commit format.
2. Open PR from `dev` to `main`.
3. Merge PR.
4. Semantic Release workflow runs, creates tag `vX.Y.Z` when releasable commits exist.
1. Push commits to `main` (direct push or merged PR), using Conventional Commit messages.
2. Open GitHub Actions and run `Semantic Release` on `main`.
3. Workflow evaluates commits and creates tag `vX.Y.Z` when releasable commits exist.
4. Workflow creates the corresponding GitHub Release.
5. CI workflow runs on that tag and publishes artifacts to PyPI.

Manual fallback (if needed):
Expand All @@ -118,5 +119,8 @@ Manual fallback (if needed):
2. Run `Semantic Release` workflow via `workflow_dispatch`.
3. If no releasable commit exists, workflow will report no new release.

Commit validation note:
- Conventional commit message checks run on both `push` and `pull_request` events.

Required repository secrets:
- `PYPI_API_TOKEN`: token used by publish job to upload wheels/sdist to PyPI.
Loading