fix(ci): robust tag detection + guard when creating releases

This commit is contained in:
GitHub Actions
2025-12-03 05:38:50 +00:00
parent a776bf6995
commit 26086989ff

View File

@@ -62,10 +62,24 @@ jobs:
env:
CHARON_TOKEN: ${{ secrets.CHARON_TOKEN }}
- name: Determine tag
id: determine_tag
run: |
# Prefer created tag output; if empty fallback to semver version
TAG="${{ steps.create_tag.outputs.tag }}"
if [ -z "$TAG" ]; then
# semver.version contains a tag value like 'vX.Y.Z' or fallback 'v0.0.0'
VERSION_RAW="${{ steps.semver.outputs.version }}"
VERSION_NO_V="${VERSION_RAW#v}"
TAG="v${VERSION_NO_V}"
fi
echo "Determined tag: $TAG"
echo "tag=$TAG" >> $GITHUB_OUTPUT
- name: Check for existing GitHub Release
id: check_release
run: |
TAG=${{ steps.create_tag.outputs.tag }}
TAG=${{ steps.determine_tag.outputs.tag }}
echo "Checking for release for tag: ${TAG}"
STATUS=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: token ${CHARON_TOKEN}" -H "Accept: application/vnd.github+json" "https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/${TAG}") || true
if [ "${STATUS}" = "200" ]; then
@@ -80,8 +94,8 @@ jobs:
if: ${{ steps.semver.outputs.changed && steps.check_release.outputs.exists == 'false' }}
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.create_tag.outputs.tag }}
name: Release ${{ steps.create_tag.outputs.tag }}
tag_name: ${{ steps.determine_tag.outputs.tag }}
name: Release ${{ steps.determine_tag.outputs.tag }}
body: ${{ steps.semver.outputs.release_notes }}
env:
CHARON_TOKEN: ${{ secrets.CHARON_TOKEN }}