@@ -35,24 +35,48 @@ jobs:
35
35
minor_pattern : " /^feat:/"
36
36
version_format : " ${major}.${minor}.${patch}"
37
37
search_commit_body : true
38
+ bump_each_commit : true
38
39
debug : true
39
40
40
41
- name : Check if new release is needed
41
42
id : check
42
43
run : |
43
- if [ "v${{ steps.semver.outputs.version }}" == "${{ steps.get_latest.outputs.latest }}" ]; then
44
- echo "No new version needed."
44
+ LATEST_TAG="${{ steps.get_latest.outputs.latest }}"
45
+ NEW_VERSION="v${{ steps.semver.outputs.version }}"
46
+
47
+ # Check if there are any commits since the latest tag
48
+ COMMITS_SINCE=$(git rev-list ${LATEST_TAG}..HEAD --count 2>/dev/null || echo "0")
49
+
50
+ if [ "$COMMITS_SINCE" -eq "0" ]; then
51
+ echo "No new commits since $LATEST_TAG."
45
52
echo "release=false" >> $GITHUB_OUTPUT
53
+ elif [ "$NEW_VERSION" == "$LATEST_TAG" ]; then
54
+ echo "Version hasn't changed ($NEW_VERSION), but there are $COMMITS_SINCE new commits."
55
+ echo "Force creating patch release..."
56
+ # Calculate next patch version manually
57
+ LATEST_WITHOUT_V=$(echo $LATEST_TAG | sed 's/^v//')
58
+ MAJOR=$(echo $LATEST_WITHOUT_V | cut -d. -f1)
59
+ MINOR=$(echo $LATEST_WITHOUT_V | cut -d. -f2)
60
+ PATCH=$(echo $LATEST_WITHOUT_V | cut -d. -f3)
61
+ NEW_PATCH=$((PATCH + 1))
62
+ NEW_VERSION="v${MAJOR}.${MINOR}.${NEW_PATCH}"
63
+ echo "version_override=${MAJOR}.${MINOR}.${NEW_PATCH}" >> $GITHUB_OUTPUT
64
+ echo "New version will be: $NEW_VERSION"
65
+ echo "release=true" >> $GITHUB_OUTPUT
46
66
else
47
- echo "New version will be: ${{ steps.semver.outputs.version }} "
67
+ echo "New version will be: $NEW_VERSION "
48
68
echo "release=true" >> $GITHUB_OUTPUT
49
69
fi
50
70
51
71
- name : Generate changelog
52
72
if : steps.check.outputs.release == 'true'
53
73
id : changelog
54
74
run : |
55
- NEW_TAG="v${{ steps.semver.outputs.version }}"
75
+ if [ -n "${{ steps.check.outputs.version_override }}" ]; then
76
+ NEW_TAG="v${{ steps.check.outputs.version_override }}"
77
+ else
78
+ NEW_TAG="v${{ steps.semver.outputs.version }}"
79
+ fi
56
80
OLD_TAG="${{ steps.get_latest.outputs.latest }}"
57
81
58
82
echo "release_notes<<EOF" >> $GITHUB_OUTPUT
94
118
if : steps.check.outputs.release == 'true'
95
119
uses : softprops/action-gh-release@v2
96
120
with :
97
- tag_name : v ${{ steps.semver.outputs.version }}
98
- name : Release v${{ steps.semver.outputs.version }}
121
+ tag_name : ${{ steps.check.outputs.version_override && format('v{0}', steps.check.outputs.version_override) || format('v{0}', steps. semver.outputs.version) }}
122
+ name : ${{ steps.check.outputs.version_override && format(' Release v{0}', steps.check.outputs.version_override) || format('Release v{0}', steps.semver.outputs.version) }}
99
123
body : ${{ steps.changelog.outputs.release_notes }}
100
124
generate_release_notes : true
0 commit comments