Skip to content

Commit 25540c9

Browse files
Copilotfriggeri
andcommitted
Add robust tag existence check and creation verification
Co-authored-by: friggeri <106686+friggeri@users.noreply.github.com>
1 parent f0f0095 commit 25540c9

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

.github/workflows/publish.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,18 @@ jobs:
213213
git config user.email "github-actions[bot]@users.noreply.github.com"
214214
git fetch --tags
215215
TAG_NAME="go/v${{ needs.version.outputs.version }}"
216-
if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
216+
# Check if tag exists locally or remotely
217+
if git rev-parse "$TAG_NAME" >/dev/null 2>&1 || git ls-remote --tags origin "refs/tags/$TAG_NAME" | grep -q "$TAG_NAME"; then
217218
echo "Tag $TAG_NAME already exists, skipping"
218219
else
219220
git tag "$TAG_NAME"
220-
git push origin "$TAG_NAME"
221-
echo "Created and pushed tag $TAG_NAME"
221+
if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
222+
git push origin "$TAG_NAME"
223+
echo "Created and pushed tag $TAG_NAME"
224+
else
225+
echo "Failed to create tag $TAG_NAME"
226+
exit 1
227+
fi
222228
fi
223229
env:
224230
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)