diff --git a/.github/workflows/auto-versioning.yml b/.github/workflows/auto-versioning.yml index dd485b30..f67a9ec7 100644 --- a/.github/workflows/auto-versioning.yml +++ b/.github/workflows/auto-versioning.yml @@ -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@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2 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 }}