Skip to content

Commit 2333236

Browse files
ci: update versioning
1 parent 10d5159 commit 2333236

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

.github/workflows/release-changelog.yaml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,25 @@ jobs:
1818
- name: 🔖 Get latest tag
1919
id: get_latest_tag
2020
run: |
21-
latest_tag=$(git describe --tags --abbrev=0 || echo "v1.0.0")
21+
latest_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "v1.0.0")
2222
echo "latest_tag=$latest_tag" >> "$GITHUB_OUTPUT"
2323
2424
- name: 🆕 Create new tag (optional on master push)
2525
if: github.event_name == 'push'
26+
id: create_new_tag
2627
run: |
27-
new_tag=$(echo "${{ steps.get_latest_tag.outputs.latest_tag }}" | awk -F. -v OFS=. '{$NF += 1 ; print}')
28+
latest_tag="${{ steps.get_latest_tag.outputs.latest_tag }}"
29+
version_without_v="${latest_tag#v}"
30+
31+
new_version=$(echo "$version_without_v" | awk -F. -v OFS=. '{$NF += 1 ; print}')
32+
new_tag="v$new_version"
33+
2834
git config user.name "GitHub Actions"
2935
git config user.email "[email protected]"
3036
git tag "$new_tag"
3137
git push origin "$new_tag"
38+
39+
echo "new_tag=$new_tag" >> "$GITHUB_OUTPUT"
3240
env:
3341
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3442

@@ -43,8 +51,8 @@ jobs:
4351
- name: 🚀 Create GitHub Release
4452
uses: softprops/action-gh-release@v2
4553
with:
46-
tag_name: ${{ steps.get_latest_tag.outputs.latest_tag }}
47-
name: Release ${{ steps.get_latest_tag.outputs.latest_tag }}
54+
tag_name: ${{ steps.create_new_tag.outputs.new_tag || steps.get_latest_tag.outputs.latest_tag }}
55+
name: Release ${{ steps.create_new_tag.outputs.new_tag || steps.get_latest_tag.outputs.latest_tag }}
4856
body: ${{ steps.changelog.outputs.changelog }}
4957
env:
5058
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)