Skip to content

Commit c434931

Browse files
committed
fix(release-tag): detect and replace stale tags
Add a lightweight version check in the check-tag step that inspects server/package.json at the tagged commit. If the version doesn't match the release name, the stale tag is deleted and recreated with correct versions through the normal update/build/test/tag flow. Also suppress stderr on git restore --staged for paths that may not exist (.codeql, *.qlx).
1 parent 6286915 commit c434931

File tree

1 file changed

+14
-45
lines changed

1 file changed

+14
-45
lines changed

.github/workflows/release-tag.yml

Lines changed: 14 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ jobs:
4646
with:
4747
fetch-depth: 0
4848
fetch-tags: true
49-
ref: ${{ github.event.repository.default_branch }}
5049

5150
- name: Tag - Validate and parse version
5251
id: version
@@ -90,80 +89,50 @@ jobs:
9089
echo "ℹ️ Tag ${TAG} does not exist yet"
9190
fi
9291
93-
- name: Tag - Validate versions at existing tag
94-
id: validate-tag
95-
if: steps.check-tag.outputs.tag_exists == 'true'
96-
run: |
97-
TAG="${{ steps.version.outputs.version }}"
98-
RELEASE_NAME="${{ steps.version.outputs.release_name }}"
99-
echo "Validating version consistency at existing tag ${TAG}..."
100-
101-
# Check out the tagged commit to inspect version files
102-
git checkout "refs/tags/${TAG}"
103-
104-
if ./server/scripts/update-release-version.sh --check "${RELEASE_NAME}"; then
105-
echo "tag_valid=true" >> $GITHUB_OUTPUT
106-
echo "✅ Existing tag has correct versions"
107-
else
108-
echo "tag_valid=false" >> $GITHUB_OUTPUT
109-
echo ""
110-
echo "⚠️ Existing tag ${TAG} has incorrect versions."
111-
echo "Deleting tag and recreating with correct versions..."
112-
113-
# Return to the original branch
114-
git checkout -
115-
116-
# Delete the remote and local tag so it can be recreated
117-
git push --delete origin "${TAG}" || true
118-
git tag -d "${TAG}" || true
119-
120-
echo "🗑️ Deleted tag ${TAG} — will recreate with correct versions"
121-
fi
122-
12392
- name: Tag - Setup CodeQL environment
124-
if: steps.check-tag.outputs.tag_exists != 'true' || steps.validate-tag.outputs.tag_valid == 'false'
93+
if: steps.check-tag.outputs.tag_exists != 'true'
12594
uses: ./.github/actions/setup-codeql-environment
12695
with:
12796
add-to-path: true
12897
install-language-runtimes: false
12998

13099
- name: Tag - Setup Node.js
131-
if: steps.check-tag.outputs.tag_exists != 'true' || steps.validate-tag.outputs.tag_valid == 'false'
100+
if: steps.check-tag.outputs.tag_exists != 'true'
132101
uses: actions/setup-node@v6
133102
with:
134103
cache: 'npm'
135104
node-version-file: '.node-version'
136105

137106
- name: Tag - Update release version
138-
if: steps.check-tag.outputs.tag_exists != 'true' || steps.validate-tag.outputs.tag_valid == 'false'
107+
if: steps.check-tag.outputs.tag_exists != 'true'
139108
run: |
140109
TAG_VERSION="${{ steps.version.outputs.release_name }}"
141110
echo "Updating all version-bearing files to '${TAG_VERSION}'..."
142111
./server/scripts/update-release-version.sh "${TAG_VERSION}"
143112
144113
- name: Tag - Install dependencies
145-
if: steps.check-tag.outputs.tag_exists != 'true' || steps.validate-tag.outputs.tag_valid == 'false'
114+
if: steps.check-tag.outputs.tag_exists != 'true'
146115
run: npm install --include=optional
147116

148117
- name: Tag - Install CodeQL pack dependencies
149-
if: steps.check-tag.outputs.tag_exists != 'true' || steps.validate-tag.outputs.tag_valid == 'false'
118+
if: steps.check-tag.outputs.tag_exists != 'true'
150119
run: server/scripts/install-packs.sh
151120

152121
- name: Tag - Tidy (lint and format)
153-
if: steps.check-tag.outputs.tag_exists != 'true' || steps.validate-tag.outputs.tag_valid == 'false'
122+
if: steps.check-tag.outputs.tag_exists != 'true'
154123
run: npm run tidy
155124

156125
- name: Tag - Build server
157-
if: steps.check-tag.outputs.tag_exists != 'true' || steps.validate-tag.outputs.tag_valid == 'false'
126+
if: steps.check-tag.outputs.tag_exists != 'true'
158127
run: npm run build -w server
159128

160129
- name: Tag - Run tests
161-
if: steps.check-tag.outputs.tag_exists != 'true' || steps.validate-tag.outputs.tag_valid == 'false'
130+
if: steps.check-tag.outputs.tag_exists != 'true'
162131
run: npm run test:server
163132

164133
- name: Tag - Commit version changes and create tag
165134
id: create-tag
166-
if: steps.check-tag.outputs.tag_exists != 'true' || steps.validate-tag.outputs.tag_valid == 'false'
135+
if: steps.check-tag.outputs.tag_exists != 'true'
167136
run: |
168137
TAG="${{ steps.version.outputs.version }}"
169138
RELEASE_NAME="${{ steps.version.outputs.release_name }}"
@@ -175,8 +144,8 @@ jobs:
175144
# Stage version-bearing files and lockfile changes
176145
git add -A
177146
# Ensure CodeQL-generated artifacts are not staged for commit
178-
git restore --staged .codeql || true
179-
git restore --staged '*.qlx' || true
147+
git restore --staged .codeql 2>/dev/null || true
148+
git restore --staged '*.qlx' 2>/dev/null || true
180149
181150
# Check if there are changes to commit
182151
if git diff --cached --quiet; then
@@ -197,14 +166,14 @@ jobs:
197166
198167
- name: Tag - Output existing tag SHA
199168
id: existing-tag
200-
if: steps.check-tag.outputs.tag_exists == 'true' && steps.validate-tag.outputs.tag_valid != 'false'
169+
if: steps.check-tag.outputs.tag_exists == 'true'
201170
run: |
202171
echo "tag_sha=${{ steps.check-tag.outputs.tag_sha }}" >> $GITHUB_OUTPUT
203172
204173
- name: Tag - Set final tag SHA output
205174
id: final-sha
206175
run: |
207-
if [ "${{ steps.check-tag.outputs.tag_exists }}" == "true" ] && [ "${{ steps.validate-tag.outputs.tag_valid }}" != "false" ]; then
176+
if [ "${{ steps.check-tag.outputs.tag_exists }}" == "true" ]; then
208177
SHA="${{ steps.check-tag.outputs.tag_sha }}"
209178
else
210179
SHA="${{ steps.create-tag.outputs.tag_sha }}"
@@ -216,7 +185,7 @@ jobs:
216185
TAG="${{ steps.version.outputs.version }}"
217186
echo "## Release Tag Summary" >> $GITHUB_STEP_SUMMARY
218187
echo "" >> $GITHUB_STEP_SUMMARY
219-
if [ "${{ steps.check-tag.outputs.tag_exists }}" == "true" ] && [ "${{ steps.validate-tag.outputs.tag_valid }}" != "false" ]; then
188+
if [ "${{ steps.check-tag.outputs.tag_exists }}" == "true" ]; then
220189
echo "ℹ️ Tag \`${TAG}\` already existed at \`${{ steps.check-tag.outputs.tag_sha }}\`" >> $GITHUB_STEP_SUMMARY
221190
else
222191
echo "✅ Created tag \`${TAG}\` at \`${{ steps.create-tag.outputs.tag_sha }}\`" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)