1414 - run : echo "Linting skipped"
1515
1616 release :
17- name : Semantic Version Tag & Release
17+ name : Semantic Tag & GitHub Release
1818 runs-on : ubuntu-latest
1919
2020 steps :
@@ -23,29 +23,31 @@ jobs:
2323 with :
2424 fetch-depth : 0
2525
26- - name : Get latest tag
27- id : get_tag
28- run : |
29- echo "LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo 'v0.0.0')" >> $GITHUB_ENV
30-
31- - name : Determine new version (semantic)
26+ - name : Determine next version (semantic, avoid duplicates)
3227 id : version
3328 run : |
34- latest=${{ env.LATEST_TAG }}
29+ latest=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
30+ echo "LATEST_TAG=$latest" >> $GITHUB_ENV
31+
3532 IFS='.' read -r major minor patch <<< "${latest#v}"
3633
3734 commit_msg=$(git log -1 --pretty=%s)
3835 echo "Latest commit message: $commit_msg"
3936
4037 if [[ "$commit_msg" == feat:* ]]; then
4138 new_tag="v$major.$((minor+1)).0"
42- elif [[ "$commit_msg" == fix:* ]]; then
43- new_tag="v$major.$minor.$((patch+1))"
4439 else
4540 new_tag="v$major.$minor.$((patch+1))"
4641 fi
4742
43+ git fetch --tags
44+ if git rev-parse "$new_tag" >/dev/null 2>&1; then
45+ echo "Tag $new_tag already exists. Bumping minor to avoid conflict..."
46+ new_tag="v$major.$((minor+1)).0"
47+ fi
48+
4849 echo "NEW_TAG=$new_tag" >> $GITHUB_ENV
50+ echo "Final tag to use: $new_tag"
4951
5052 - name : Create tag and push
5153 run : |
8789 release-${{ env.NEW_TAG }}.zip
8890 release-${{ env.NEW_TAG }}.tar.gz
8991 env :
90- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
92+ GITHUB_TOKEN : ${{ secrets.PERSONAL_TOKEN }}
0 commit comments