Skip to content

Commit 886e54d

Browse files
committed
ci: fix tag name for release action
1 parent dc131d7 commit 886e54d

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,28 @@ jobs:
3131

3232
- name: Calculate and create tag
3333
id: version
34+
if: ${{ !inputs.force-major }}
3435
uses: mathieudutour/github-tag-action@v6.2
3536
with:
3637
github_token: ${{ secrets.GITHUB_TOKEN }}
37-
default_bump: ${{ inputs.force-major && 'major' || 'patch' }}
38+
default_bump: patch
3839
release_branches: master
40+
tag_prefix: ""
41+
42+
- name: Force major version
43+
id: major
44+
if: ${{ inputs.force-major }}
45+
run: |
46+
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0")
47+
IFS='.' read -r MAJOR MINOR PATCH <<< "$LATEST_TAG"
48+
NEW_VERSION="$((MAJOR + 1)).0.0"
49+
echo "new_tag=$NEW_VERSION" >> $GITHUB_OUTPUT
50+
git tag "$NEW_VERSION"
51+
git push origin "$NEW_VERSION"
52+
53+
- name: Set release tag
54+
id: release
55+
run: echo "tag=${{ steps.version.outputs.new_tag || steps.major.outputs.new_tag }}" >> $GITHUB_OUTPUT
3956

4057
- name: Build with Gradle
4158
run: ./gradlew build
@@ -58,8 +75,8 @@ jobs:
5875
env:
5976
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6077
run: |
61-
gh release create "${{ steps.version.outputs.new_tag }}" \
62-
--title "${{ steps.version.outputs.new_tag }}" \
78+
gh release create "${{ steps.release.outputs.tag }}" \
79+
--title "${{ steps.release.outputs.tag }}" \
6380
--generate-notes
6481
6582
- name: Upload JReleaser logs

0 commit comments

Comments
 (0)