fix(ci): prevent duplicate tags and validate tag format in release workflow (#12847)

- Add tag format validation (must start with 'v')
- Check for duplicate tags without 'v' prefix
- Prevent release notes from using wrong base comparison
- Add validate-tag-format job dependency to create_release

Fixes tag duplication issue that caused v1.9.0 release notes to miss 58 commits.

Root cause: Duplicate tags (1.8.3 vs v1.8.3) caused GitHub's generateReleaseNotes
to pick the wrong base tag due to alphabetical sorting.

This ensures future releases will:
1. Only accept tags with 'v' prefix (v1.2.3 format)
2. Detect and reject releases if duplicate tags exist
3. Generate correct release notes with proper commit history
This commit is contained in:
vjgit96
2026-04-22 17:52:07 -04:00
committed by GitHub
parent bc2bd31c05
commit a754961428

View File

@ -98,6 +98,46 @@ jobs:
echo "Validated: '${{ inputs.release_tag }}' is a valid tag."
validate-tag-format:
name: Validate Tag Format and Check for Duplicates
runs-on: ubuntu-latest
needs: [validate-tag]
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Validate Tag Has v Prefix
run: |
TAG="${{ inputs.release_tag }}"
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "❌ Error: Tag must start with 'v' and follow semver format (v1.2.3)"
echo " Got: $TAG"
echo ""
echo "This is required to ensure GitHub's generateReleaseNotes uses the correct base comparison."
exit 1
fi
echo "✅ Tag format is valid: $TAG"
- name: Check for Duplicate Tag Without v Prefix
run: |
TAG="${{ inputs.release_tag }}"
TAG_WITHOUT_V="${TAG#v}"
if git rev-parse "$TAG_WITHOUT_V" >/dev/null 2>&1; then
echo "❌ Error: Duplicate tag without 'v' prefix exists: $TAG_WITHOUT_V"
echo " This will cause release notes to use the wrong base comparison."
echo ""
echo " The tag '$TAG_WITHOUT_V' points to commit: $(git rev-parse --short $TAG_WITHOUT_V)"
echo " The tag '$TAG' points to commit: $(git rev-parse --short $TAG)"
echo ""
echo " To fix this, delete the duplicate tag:"
echo " git push origin :refs/tags/$TAG_WITHOUT_V"
exit 1
fi
echo "✅ No duplicate tag found"
validate-dependencies:
name: Validate Release Dependencies
runs-on: ubuntu-latest
@ -1000,14 +1040,15 @@ jobs:
create_release:
name: Create Release
runs-on: ubuntu-latest
needs: [determine-main-version, build-main, publish-main]
needs: [determine-main-version, build-main, publish-main, validate-tag-format]
if: |
always() &&
!cancelled() &&
!inputs.dry_run &&
inputs.create_release &&
needs.build-main.result == 'success' &&
needs.publish-main.result == 'success'
needs.publish-main.result == 'success' &&
needs.validate-tag-format.result == 'success'
steps:
- uses: actions/download-artifact@v4
with: