Skip to content

Commit 5b9b797

Browse files
authored
Merge pull request #3 from krypton-byte/dev
fix(test): update workflows for commit message validation and release…
2 parents 294be95 + b940d91 commit 5b9b797

3 files changed

Lines changed: 50 additions & 50 deletions

File tree

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
name: Conventional Commits
22

33
on:
4+
push:
5+
tags-ignore:
6+
- "v*"
47
pull_request:
5-
types: [opened, synchronize, reopened, edited]
8+
types: [opened, synchronize, reopened]
69

710
permissions:
811
contents: read
@@ -20,27 +23,31 @@ jobs:
2023
- uses: actions/setup-python@v5
2124
with:
2225
python-version: "3.12"
23-
- name: Check commit subjects in PR range
26+
- name: Resolve commit range
27+
id: commit_range
2428
run: |
25-
python scripts/check_commit_message.py --range "${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}"
29+
set -euo pipefail
2630
27-
pr-title:
28-
name: Validate PR title
29-
runs-on: ubuntu-latest
30-
steps:
31-
- uses: amannn/action-semantic-pull-request@v5
32-
env:
33-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34-
with:
35-
types: |
36-
build
37-
chore
38-
ci
39-
docs
40-
feat
41-
fix
42-
perf
43-
refactor
44-
style
45-
test
46-
requireScope: false
31+
if [ "${GITHUB_EVENT_NAME}" = "pull_request" ]; then
32+
range="${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}"
33+
else
34+
before_sha="${{ github.event.before }}"
35+
after_sha="${GITHUB_SHA}"
36+
37+
if [ "${before_sha}" = "0000000000000000000000000000000000000000" ]; then
38+
if git rev-parse "${after_sha}^" >/dev/null 2>&1; then
39+
range="${after_sha}^..${after_sha}"
40+
else
41+
range="${after_sha}..${after_sha}"
42+
fi
43+
else
44+
range="${before_sha}..${after_sha}"
45+
fi
46+
fi
47+
48+
echo "range=${range}" >> "$GITHUB_OUTPUT"
49+
echo "Using commit range: ${range}"
50+
51+
- name: Check commit subjects in range
52+
run: |
53+
python scripts/check_commit_message.py --range "${{ steps.commit_range.outputs.range }}"

.github/workflows/release.yml

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
name: Semantic Release
22

33
on:
4-
pull_request:
5-
branches:
6-
- main
7-
types:
8-
- closed
94
workflow_dispatch:
105

116
permissions:
@@ -18,26 +13,13 @@ concurrency:
1813

1914
jobs:
2015
release:
21-
if: >-
22-
${{
23-
github.event_name == 'workflow_dispatch' ||
24-
(
25-
github.event_name == 'pull_request' &&
26-
github.event.pull_request.merged == true &&
27-
github.event.pull_request.base.ref == 'main' &&
28-
github.event.pull_request.head.ref == 'dev'
29-
)
30-
}}
3116
runs-on: ubuntu-latest
3217
steps:
3318
- name: Log trigger context
3419
run: |
3520
echo "event=${GITHUB_EVENT_NAME}"
3621
echo "ref=${GITHUB_REF}"
3722
echo "actor=${GITHUB_ACTOR}"
38-
echo "pr_merged=${{ github.event.pull_request.merged }}"
39-
echo "pr_base=${{ github.event.pull_request.base.ref }}"
40-
echo "pr_head=${{ github.event.pull_request.head.ref }}"
4123
4224
- uses: actions/checkout@v4
4325
with:
@@ -88,12 +70,19 @@ jobs:
8870
8971
if [ "${after_sha}" = "${{ steps.baseline.outputs.sha }}" ] && [ "${after_tag}" = "${{ steps.baseline.outputs.tag }}" ]; then
9072
echo "released=false" >> "$GITHUB_OUTPUT"
91-
echo "No new release generated from this merge."
73+
echo "No new release generated in this run."
9274
else
9375
echo "released=true" >> "$GITHUB_OUTPUT"
9476
echo "Release generated. Latest tag: ${after_tag:-none}"
9577
fi
9678
79+
- name: Create GitHub release
80+
if: ${{ steps.release_result.outputs.released == 'true' && startsWith(steps.release_result.outputs.after_tag, 'v') }}
81+
uses: softprops/action-gh-release@v2
82+
with:
83+
tag_name: ${{ steps.release_result.outputs.after_tag }}
84+
generate_release_notes: true
85+
9786
- name: Trigger CI release build on new tag
9887
if: ${{ steps.release_result.outputs.released == 'true' && startsWith(steps.release_result.outputs.after_tag, 'v') }}
9988
env:

CONTRIBUTING.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Examples:
7171
1. Create a feature branch from `main`.
7272
2. Keep PR scope focused and small.
7373
3. Ensure CI is green.
74-
4. Use a Conventional Commit style PR title.
74+
4. Use Conventional Commit style commit messages (`feat:`, `fix:`, `perf:`, etc.).
7575
5. Fill the PR template completely.
7676

7777
Recommended merge strategy: squash merge.
@@ -89,11 +89,12 @@ Include:
8989

9090
## Release Flow Overview
9191

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

9899
## Simple Trigger Guide
99100

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

107108
How to trigger semantic release until publish to PyPI:
108109

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

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

122+
Commit validation note:
123+
- Conventional commit message checks run on both `push` and `pull_request` events.
124+
121125
Required repository secrets:
122126
- `PYPI_API_TOKEN`: token used by publish job to upload wheels/sdist to PyPI.

0 commit comments

Comments
 (0)