@@ -622,10 +622,49 @@ jobs:
622622 - name : List artifacts
623623 run : ls -R artifacts
624624
625+ # Re-pushing the same pre-release tag fails here if a GitHub Release
626+ # already exists for that tag. Remove the old release (tag ref stays).
627+ - name : Remove existing pre-release (same tag) if present
628+ env :
629+ GH_TOKEN : ${{ github.token }}
630+ run : |
631+ set -euo pipefail
632+ TAG="${GITHUB_REF_NAME}"
633+ case "$TAG" in *alpha*|*beta*|*rc*) ;; *)
634+ echo "Not a pre-release tag pattern; skip release delete."
635+ exit 0
636+ ;;
637+ esac
638+ CODE=$(curl -sS -o /tmp/rel.json -w "%{http_code}" \
639+ -H "Authorization: Bearer ${GH_TOKEN}" \
640+ -H "Accept: application/vnd.github+json" \
641+ "https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/${TAG}")
642+ if [ "$CODE" = "404" ]; then
643+ echo "No existing GitHub Release for ${TAG}."
644+ exit 0
645+ fi
646+ if [ "$CODE" != "200" ]; then
647+ echo "Unexpected HTTP ${CODE} when looking up release for ${TAG}"
648+ cat /tmp/rel.json || true
649+ exit 1
650+ fi
651+ RID=$(jq -r '.id // empty' /tmp/rel.json)
652+ if [ -z "$RID" ] || [ "$RID" = "null" ]; then
653+ echo "No release id in response."
654+ exit 0
655+ fi
656+ echo "Deleting GitHub Release id=${RID} for tag ${TAG} (tag ref is unchanged)."
657+ curl -sS -X DELETE \
658+ -H "Authorization: Bearer ${GH_TOKEN}" \
659+ -H "Accept: application/vnd.github+json" \
660+ "https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/${RID}"
661+
625662 - name : Create GitHub Release (attach assets)
626663 uses : softprops/action-gh-release@v2
627664 with :
628665 name : SentraCore ${{ github.ref_name }}
666+ prerelease : ${{ contains(github.ref_name, 'alpha') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'rc') }}
667+ make_latest : ${{ !(contains(github.ref_name, 'alpha') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'rc')) }}
629668 body : |
630669 ## Highlights
631670 - Updated dashboard UI with new home page and settings page.
0 commit comments