Skip to content

Commit 541c63c

Browse files
Add verification to check if tag already exists before release
Co-authored-by: thomasturrell <1552612+thomasturrell@users.noreply.github.com>
1 parent 7ba8bc6 commit 541c63c

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

.github/workflows/manual-release.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,28 @@ jobs:
121121
fetch-depth: 0
122122
persist-credentials: true
123123

124+
- name: Verify tag does not already exist
125+
run: |
126+
TAG_NAME="${{ steps.release.outputs.tag_name }}"
127+
128+
echo "Checking if tag $TAG_NAME already exists..."
129+
130+
# Check if tag exists locally
131+
if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
132+
echo "::error::Tag $TAG_NAME already exists in the repository."
133+
echo "Please use a different version number or delete the existing tag first."
134+
exit 1
135+
fi
136+
137+
# Check if tag exists on remote
138+
if git ls-remote --tags origin "$TAG_NAME" | grep -q "$TAG_NAME"; then
139+
echo "::error::Tag $TAG_NAME already exists on remote."
140+
echo "Please use a different version number or delete the existing tag first."
141+
exit 1
142+
fi
143+
144+
echo "Tag $TAG_NAME does not exist. Proceeding with release."
145+
124146
- name: Set up JDK 25
125147
uses: actions/setup-java@v5
126148
with:

0 commit comments

Comments
 (0)