@@ -47,25 +47,54 @@ jobs:
47
47
uses : SolaceDev/solace-public-workflows/.github/actions/hatch-setup@main
48
48
49
49
- name : Get Current Version
50
+ id : current_version
50
51
run : |
51
52
CURRENT_VERSION=$(hatch version)
52
53
echo "CURRENT_VERSION=${CURRENT_VERSION}" >> $GITHUB_ENV
53
54
54
- - name : Fail if the current version doesn't exist
55
- if : env.CURRENT_VERSION == ''
56
- run : exit 1
55
+ - name : Check if last commit was a version bump commit
56
+ id : check_bump
57
+ run : |
58
+ LAST_COMMIT_MSG=$(git log -1 --pretty=%B)
59
+ echo "Last commit: $LAST_COMMIT_MSG"
60
+ if echo "$LAST_COMMIT_MSG" | grep -q "\[ci skip\] Bump version to"; then
61
+ echo "Previous commit was a version bump. Skipping version bump."
62
+ echo "SKIP_BUMP=1" >> $GITHUB_ENV
63
+ else
64
+ echo "SKIP_BUMP=0" >> $GITHUB_ENV
65
+ fi
57
66
58
67
- name : Bump Version
68
+ id : bump_version
59
69
run : |
60
- hatch version "${{ github.event.inputs.version }}"
61
- NEW_VERSION=$(hatch version)
62
- echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV
70
+ if [ "$SKIP_BUMP" = "1" ]; then
71
+ echo "Skipping version bump as the last commit was a version bump."
72
+ echo "NEW_VERSION=${CURRENT_VERSION}" >> $GITHUB_ENV
73
+ else
74
+ if [ -n "${{ github.event.inputs.full_version }}" ]; then
75
+ if [[ "${{ github.event.inputs.full_version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
76
+ hatch version "${{ github.event.inputs.full_version }}"
77
+ else
78
+ echo "Invalid full_version provided: ${{ github.event.inputs.full_version }}. Expected format x.y.z."
79
+ exit 1
80
+ fi
81
+ else
82
+ hatch version "${{ github.event.inputs.version }}"
83
+ fi
84
+ NEW_VERSION=$(hatch version)
85
+ echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV
86
+ fi
87
+
88
+ - name : Fail if the current version doesn't exist
89
+ if : env.CURRENT_VERSION == ''
90
+ run : exit 1
63
91
64
92
- name : Commit new version
93
+ if : ${{ env.SKIP_BUMP == '0' }}
65
94
run : |
66
95
git config --local user.email "action@github.com"
67
96
git config --local user.name "GitHub Action"
68
- git commit -a -m "[ci skip] Bump version to $NEW_VERSION"
97
+ git commit -a -m "[ci skip] Bump version to ${ NEW_VERSION} "
69
98
git push
70
99
71
100
- name : Build project for distribution
0 commit comments