From a3696fe18259c4c757644a6673bbefb89aed89c1 Mon Sep 17 00:00:00 2001 From: Julian Pawlowski <75446+jpawlowski@users.noreply.github.com> Date: Wed, 3 Dec 2025 13:45:21 +0000 Subject: [PATCH] ci(release): auto-delete inappropriate version tags with clear error messaging Release workflow now automatically deletes tags when version number doesn't match commit types (e.g., PATCH bump when MINOR needed for features). Changes: - New step 'Delete inappropriate version tag' runs after version_check - Automatically deletes tag and exits with error if version inappropriate - All subsequent steps conditional on successful version validation - Improved warning message: removed confusing 'X.Y.Z' placeholder - Added notice: 'This tag will be automatically deleted in the next step' - Removed redundant 'Version Check Summary' step Impact: Users get immediate, clear feedback when pushing wrong version tags. Workflow fails fast with actionable error message instead of creating release with embedded warning. No manual tag deletion needed. --- .github/workflows/release.yml | 39 ++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0adc69a..a0be63c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -180,9 +180,11 @@ jobs: echo "**Commits analyzed:** Breaking=$BREAKING, Features=$FEAT, Fixes=$FIX" echo "" echo "**To fix:**" - echo "1. Delete the tag: \`git tag -d v$TAG_VERSION && git push origin :refs/tags/v$TAG_VERSION\`" - echo "2. Run locally: \`./scripts/release/suggest-version\`" - echo "3. Create correct tag: \`./scripts/release/prepare X.Y.Z\`" + echo "1. Run locally: \`./scripts/release/suggest-version\`" + echo "2. Create correct tag: \`./scripts/release/prepare \`" + echo "3. Push the corrected tag: \`git push origin v\`" + echo "" + echo "**This tag will be automatically deleted in the next step.**" echo "EOF" } >> $GITHUB_OUTPUT else @@ -190,7 +192,19 @@ jobs: echo "warning=" >> $GITHUB_OUTPUT fi + - name: Delete inappropriate version tag + if: steps.version_check.outputs.warning != '' + run: | + TAG_NAME="${GITHUB_REF#refs/tags/}" + echo "❌ Deleting tag $TAG_NAME (version not appropriate for changes)" + echo "" + echo "${{ steps.version_check.outputs.warning }}" + echo "" + git push origin --delete "$TAG_NAME" + exit 1 + - name: Install git-cliff + if: steps.version_check.outputs.warning == '' run: | wget https://github.com/orhun/git-cliff/releases/download/v2.4.0/git-cliff-2.4.0-x86_64-unknown-linux-gnu.tar.gz tar -xzf git-cliff-2.4.0-x86_64-unknown-linux-gnu.tar.gz @@ -198,6 +212,7 @@ jobs: git-cliff --version - name: Generate release notes + if: steps.version_check.outputs.warning == '' id: release_notes run: | FROM_TAG="${{ steps.previoustag.outputs.previous_tag }}" @@ -216,15 +231,6 @@ jobs: fi echo "title=$TITLE" >> $GITHUB_OUTPUT - # Append version warning if present - WARNING="${{ steps.version_check.outputs.warning }}" - if [ -n "$WARNING" ]; then - echo "" >> release-notes.md - echo "---" >> release-notes.md - echo "" >> release-notes.md - echo "$WARNING" >> release-notes.md - fi - # Output for GitHub Actions { echo 'notes<> $GITHUB_OUTPUT - - name: Version Check Summary - if: steps.version_check.outputs.warning != '' - run: | - echo "### ⚠️ Version Mismatch Detected" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "${{ steps.version_check.outputs.warning }}" >> $GITHUB_STEP_SUMMARY - - name: Create GitHub Release + if: steps.version_check.outputs.warning == '' uses: softprops/action-gh-release@v2 with: name: ${{ steps.release_notes.outputs.title }} @@ -251,6 +251,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Summary + if: steps.version_check.outputs.warning == '' run: | echo "✅ Release notes generated and published!" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY