Skip to content

Commit 581cf2f

Browse files
authored
fix: update weekly release workflow to detect squash-merged PRs (#45)
fix(workflows): update weekly release to detect squash-merged PRs Fix the weekly release workflow to properly detect squash-merged PRs and handle alpha semantic versioning correctly. Changes: - Replace --merges flag with all commits detection - Look for PR references in squash commits (#123) - Detect conventional commit types (feat, fix, refactor, etc.) - Look for "breaking change" keywords in commit bodies - Implement alpha versioning rules (v0.x.x): - Major bumps become minor bumps while in alpha - Breaking changes trigger v0.1.0 -> v0.2.0 - Features trigger minor bumps - Fixes trigger patch bumps - Update release notes to show all commits, not just merges This ensures the weekly release workflow runs correctly regardless of merge strategy (squash, merge commit, or rebase). Fixes detection of recent breaking changes in PR #44.
1 parent 9d023b6 commit 581cf2f

File tree

1 file changed

+32
-15
lines changed

1 file changed

+32
-15
lines changed

.github/workflows/release-weekly.yml

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ jobs:
6161
exit 0
6262
fi
6363
64-
# Get merge commits since last tag
65-
MERGE_COMMITS=$(git log $LAST_TAG..HEAD --merges --pretty=format:"%s %b" || echo "")
64+
# Get all commits since last tag (including squash-merged PRs)
65+
ALL_COMMITS=$(git log $LAST_TAG..HEAD --pretty=format:"%s %b" || echo "")
6666
67-
if [ -z "$MERGE_COMMITS" ]; then
67+
if [ -z "$ALL_COMMITS" ]; then
6868
echo "No changes since last release"
6969
echo "has_changes=false" >> $GITHUB_OUTPUT
7070
exit 0
@@ -77,21 +77,30 @@ jobs:
7777
echo "Using manual version bump: $FORCE_BUMP"
7878
echo "version_bump=$FORCE_BUMP" >> $GITHUB_OUTPUT
7979
else
80-
# Determine version bump from semantic labels in merge commits
81-
# Look for semantic:major, semantic:minor, semantic:patch in commit messages
82-
if echo "$MERGE_COMMITS" | grep -qi "semantic:major"; then
80+
# Determine version bump from commit messages
81+
# Priority: breaking > feat > fix
82+
# Look for:
83+
# - "BREAKING CHANGE" or "breaking change" in commit body
84+
# - "feat:" or "feature:" prefix (new feature)
85+
# - "fix:" prefix (bug fix)
86+
# - Conventional commit types
87+
88+
if echo "$ALL_COMMITS" | grep -qiE "(BREAKING CHANGE|breaking change)"; then
89+
echo "Detected breaking change in commits"
8390
echo "version_bump=major" >> $GITHUB_OUTPUT
84-
elif echo "$MERGE_COMMITS" | grep -qi "semantic:minor"; then
91+
elif echo "$ALL_COMMITS" | grep -qiE "^(feat|feature|refactor)\("; then
92+
echo "Detected feature or refactor in commits"
8593
echo "version_bump=minor" >> $GITHUB_OUTPUT
86-
elif echo "$MERGE_COMMITS" | grep -qi "semantic:patch"; then
94+
elif echo "$ALL_COMMITS" | grep -qiE "^(fix|chore|docs|test|ci)\("; then
95+
echo "Detected fix/chore/docs in commits"
8796
echo "version_bump=patch" >> $GITHUB_OUTPUT
8897
else
89-
echo "No semantic labels found, defaulting to patch"
98+
echo "No conventional commit prefix found, defaulting to patch"
9099
echo "version_bump=patch" >> $GITHUB_OUTPUT
91100
fi
92101
fi
93102
94-
# Calculate new version
103+
# Calculate new version with alpha versioning rules
95104
BUMP_TYPE=$(grep "version_bump=" $GITHUB_OUTPUT | cut -d'=' -f2)
96105
CURRENT_VERSION=$LAST_TAG
97106
@@ -101,6 +110,12 @@ jobs:
101110
MINOR=$(echo $VERSION_NO_V | cut -d. -f2)
102111
PATCH=$(echo $VERSION_NO_V | cut -d. -f3)
103112
113+
# Alpha versioning (v0.x.x): major bumps become minor bumps
114+
if [ "$MAJOR" = "0" ] && [ "$BUMP_TYPE" = "major" ]; then
115+
echo "Alpha versioning: treating major bump as minor bump"
116+
BUMP_TYPE="minor"
117+
fi
118+
104119
case $BUMP_TYPE in
105120
major)
106121
NEW_VERSION="v$((MAJOR + 1)).0.0"
@@ -281,17 +296,19 @@ jobs:
281296
282297
**Version Bump:** ${VERSION_BUMP^^}
283298
284-
### Merged Pull Requests
299+
### Changes
285300
286301
EOF
287302
288-
# Get merged PRs since last release
303+
# Get all commits since last release (including squash-merged PRs)
289304
if [ "$LAST_TAG" = "v0.0.0" ]; then
290-
# First release - show all merge commits
291-
git log --merges --pretty=format:"- %s (%h)" >> releases/$NEW_VERSION/RELEASE_NOTES.md
305+
# First release - show all commits with PR numbers
306+
git log --pretty=format:"- %s (%h)" | grep -E "\(#[0-9]+\)" >> releases/$NEW_VERSION/RELEASE_NOTES.md || \
307+
git log --pretty=format:"- %s (%h)" >> releases/$NEW_VERSION/RELEASE_NOTES.md
292308
else
293309
# Subsequent releases - show commits since last tag
294-
git log $LAST_TAG..HEAD --merges --pretty=format:"- %s (%h)" >> releases/$NEW_VERSION/RELEASE_NOTES.md
310+
git log $LAST_TAG..HEAD --pretty=format:"- %s (%h)" | grep -E "\(#[0-9]+\)" >> releases/$NEW_VERSION/RELEASE_NOTES.md || \
311+
git log $LAST_TAG..HEAD --pretty=format:"- %s (%h)" >> releases/$NEW_VERSION/RELEASE_NOTES.md
295312
fi
296313
297314
cat >> releases/$NEW_VERSION/RELEASE_NOTES.md <<EOF

0 commit comments

Comments
 (0)