Skip to content

Commit 7769055

Browse files
TMHSDigitalclaude
andcommitted
ci: release only after Validate passes and for release-worthy commits (#37)
release.yml ran on every push to main in parallel with Validate, so a failing commit still got a version bump, tag and GitHub Release, and any commit (docs, chore) produced at least a patch release. Breaking changes were only detected for feat!. - Trigger Release via workflow_run on Validate (completed, main) and run only when it succeeded for a push. - Bump major for any `<type>!:` subject or a BREAKING CHANGE footer, minor for feat, patch for fix/perf, and skip the release otherwise. - Describe the new behaviour in CLAUDE.md and AGENTS.md. The bump rules were checked locally against sample subjects/bodies: docs+chore -> none, fix! -> major, BREAKING CHANGE footer -> major, feat+fix -> minor, fix -> patch, ci -> none. Fixes #37 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent fdacbd7 commit 7769055

3 files changed

Lines changed: 32 additions & 16 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
name: Release
22

3+
# Release only after Validate has passed for a push to main, so a failing
4+
# commit never produces a version bump, tag or GitHub Release.
35
on:
4-
push:
6+
workflow_run:
7+
workflows: [Validate]
8+
types: [completed]
59
branches: [main]
610

711
permissions:
@@ -15,9 +19,13 @@ jobs:
1519
version-and-release:
1620
name: Bump version, tag, and release
1721
runs-on: ubuntu-latest
22+
if: >-
23+
github.event.workflow_run.conclusion == 'success' &&
24+
github.event.workflow_run.event == 'push'
1825
steps:
1926
- uses: actions/checkout@v7
2027
with:
28+
ref: main
2129
fetch-depth: 0
2230
token: ${{ secrets.GITHUB_TOKEN }}
2331

@@ -31,22 +39,28 @@ jobs:
3139
- name: Determine bump type from commits
3240
id: bump
3341
run: |
34-
# Get commits since last tag (or all if no tags)
42+
# Commits since last tag (or all if no tags)
3543
last_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
36-
if [ -z "$last_tag" ]; then
37-
commits=$(git log --oneline --format="%s")
38-
else
39-
commits=$(git log "$last_tag"..HEAD --oneline --format="%s")
44+
range="HEAD"
45+
if [ -n "$last_tag" ]; then
46+
range="$last_tag..HEAD"
4047
fi
48+
subjects=$(git log "$range" --format="%s")
49+
bodies=$(git log "$range" --format="%B")
4150
4251
echo "Commits since last release:"
43-
echo "$commits"
52+
echo "$subjects"
4453
45-
bump="patch"
46-
if echo "$commits" | grep -qiE "^(feat|feature)(\(.+\))?!:|BREAKING CHANGE"; then
54+
# major: any "<type>(scope)!:" subject or a BREAKING CHANGE footer
55+
# minor: feat; patch: fix or perf; otherwise (docs, chore, ci,
56+
# test, refactor, style, build) no release.
57+
bump="none"
58+
if echo "$subjects" | grep -qE "^[a-zA-Z]+(\(.+\))?!:" || echo "$bodies" | grep -qE "^BREAKING[ -]CHANGE:"; then
4759
bump="major"
48-
elif echo "$commits" | grep -qiE "^(feat|feature)(\(.+\))?:"; then
60+
elif echo "$subjects" | grep -qiE "^(feat|feature)(\(.+\))?:"; then
4961
bump="minor"
62+
elif echo "$subjects" | grep -qiE "^(fix|perf)(\(.+\))?:"; then
63+
bump="patch"
5064
fi
5165
5266
echo "bump=$bump" >> "$GITHUB_OUTPUT"
@@ -64,6 +78,7 @@ jobs:
6478
major) major=$((major + 1)); minor=0; patch=0 ;;
6579
minor) minor=$((minor + 1)); patch=0 ;;
6680
patch) patch=$((patch + 1)) ;;
81+
none) ;;
6782
esac
6883
6984
new_version="$major.$minor.$patch"

‎AGENTS.md‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ This is a Cursor IDE plugin for FiveM/RedM (CFX) resource development. It contai
2626
- **Single branch**: `main` only. No develop/release branches.
2727
- **Conventional commits** are required. The release workflow parses them:
2828
- `feat:` or `feat(scope):` -- triggers a **minor** version bump
29-
- `feat!:` or `BREAKING CHANGE` -- triggers a **major** version bump
30-
- Everything else (`fix:`, `chore:`, `docs:`, `refactor:`, etc.) -- triggers a **patch** bump
29+
- Any `<type>!:` (for example `feat!:` or `fix!:`) or a `BREAKING CHANGE:` footer -- triggers a **major** version bump
30+
- `fix:` or `perf:` -- triggers a **patch** bump
31+
- Everything else (`chore:`, `docs:`, `ci:`, `test:`, `refactor:`, etc.) -- no release
3132
- Commit messages should be concise and describe the "why", not the "what".
3233

3334
## CI/CD workflows
@@ -44,9 +45,9 @@ Checks:
4445
- fxmanifest.lua templates have `fx_version`, `games`, `'cerulean'`
4546
- Python syntax for all MCP server modules
4647

47-
### `release.yml` (runs on push to main, ignores docs/md/github changes)
48+
### `release.yml` (runs after `validate.yml` succeeds for a push to main)
4849

49-
Automatic flow:
50+
Automatic flow (skipped entirely when Validate fails or there are no release-worthy commits):
5051
1. Reads current version from `plugin.json`
5152
2. Determines bump type from conventional commit messages since last tag
5253
3. Computes new semver version

‎CLAUDE.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ python .github/scripts/transform_natives.py
117117

118118
## Release Workflow
119119

120-
Releases are automated. The `release.yml` workflow:
120+
Releases are automated. The `release.yml` workflow runs only after the `Validate` workflow succeeds for a push to `main`, and:
121121

122122
1. Reads conventional commits since the last tag.
123-
2. Computes the next semver bump (PATCH for `fix:`, MINOR for `feat:`, MAJOR for `BREAKING CHANGE`).
123+
2. Computes the next semver bump (PATCH for `fix:`/`perf:`, MINOR for `feat:`, MAJOR for `<type>!:` or a `BREAKING CHANGE:` footer). Pushes with only `docs:`, `chore:`, `ci:`, `test:`, `refactor:` and similar commits do not release.
124124
3. Updates `plugin.json` `version` and the README version badge.
125125
4. Creates the tag, the GitHub Release, and floating major / minor tags.
126126
5. Invokes `release-doc-sync` to update `**Version:**` in this file and prepend a CHANGELOG entry.

0 commit comments

Comments
 (0)