Skip to content

Commit 3cf98fb

Browse files
committed
fix: release automatic versions
1 parent 1431822 commit 3cf98fb

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

.github/workflows/release.yml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ on:
44
push:
55
branches:
66
- master
7+
workflow_dispatch:
8+
inputs:
9+
force:
10+
description: 'Force release even if tag exists'
11+
required: false
12+
default: false
13+
type: boolean
714

815
jobs:
916
release:
@@ -17,7 +24,8 @@ jobs:
1724
uses: actions/checkout@v4
1825
with:
1926
fetch-depth: 0
20-
token: ${{ github.token }}
27+
token: ${{ secrets.GITHUB_TOKEN }}
28+
fetch-tags: true
2129

2230
- name: Set up JDK
2331
uses: actions/setup-java@v4
@@ -33,11 +41,19 @@ jobs:
3341
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
3442
echo "Extracted version: $VERSION"
3543
44+
- name: Fetch all tags
45+
run: git fetch --tags --force
46+
3647
- name: Check if tag exists
3748
id: check_tag
3849
run: |
3950
TAG="${{ steps.get_version.outputs.tag }}"
40-
if git rev-parse "$TAG" >/dev/null 2>&1; then
51+
FORCE_RELEASE="${{ github.event.inputs.force }}"
52+
53+
if [ "$FORCE_RELEASE" = "true" ] || [ "$FORCE_RELEASE" = true ]; then
54+
echo "exists=false" >> $GITHUB_OUTPUT
55+
echo "Force release enabled, proceeding with release"
56+
elif git rev-parse "$TAG" >/dev/null 2>&1; then
4157
echo "exists=true" >> $GITHUB_OUTPUT
4258
echo "Tag $TAG already exists, skipping release"
4359
else
@@ -82,8 +98,14 @@ jobs:
8298
TAG="${{ steps.get_version.outputs.tag }}"
8399
git config user.name "github-actions[bot]"
84100
git config user.email "github-actions[bot]@users.noreply.github.com"
101+
102+
# Delete tag if it exists locally (for force release)
103+
if git rev-parse "$TAG" >/dev/null 2>&1; then
104+
git tag -d "$TAG" || true
105+
fi
106+
85107
git tag -a "$TAG" -m "Release ${{ steps.get_version.outputs.version }}"
86-
git push origin "$TAG"
108+
git push origin "$TAG" --force
87109
88110
- name: Create GitHub Release
89111
if: steps.check_tag.outputs.exists == 'false'

0 commit comments

Comments
 (0)