11name : Release Base Gems
2- run-name : Base Gems ${{ inputs.release_version }} (${{ inputs.confirm_live_publication && 'publish' || 'verify' }})
2+ run-name : Base Gems ${{ inputs.release_version }} (${{ inputs.curseforge_only && 'CurseForge only' || inputs. confirm_live_publication && 'publish' || 'verify' }})
33
44on :
55 workflow_dispatch :
2222 - beta
2323 - alpha
2424 confirm_live_publication :
25- description : Publish to CurseForge and GitHub after verification
25+ description : Publish after verification; CurseForge-only mode skips GitHub
26+ default : false
27+ required : true
28+ type : boolean
29+ curseforge_only :
30+ description : Retry only CurseForge for an existing, verified release tag
2631 default : false
2732 required : true
2833 type : boolean
@@ -111,22 +116,37 @@ jobs:
111116 -H "X-Api-Token: $CURSEFORGE_TOKEN" \
112117 https://minecraft.curseforge.com/api/game/versions >/dev/null
113118
114- - name : Reserve the release tag
119+ - name : Create or verify the release tag
115120 if : inputs.confirm_live_publication
116121 env :
117122 GH_TOKEN : ${{ github.token }}
118123 RELEASE_SHA : ${{ steps.candidate.outputs.sha }}
124+ CURSEFORGE_ONLY : ${{ inputs.curseforge_only }}
119125 run : |
120126 set -euo pipefail
121127 if [[ "$(gh api "repos/$GITHUB_REPOSITORY/branches/$RELEASE_BRANCH" --jq .commit.sha)" != "$RELEASE_SHA" ]]; then
122128 echo "$RELEASE_BRANCH moved during verification. Dispatch again for the new tip." >&2
123129 exit 1
124130 fi
125- if ! gh api --method POST "repos/$GITHUB_REPOSITORY/git/refs" \
126- -f ref="refs/tags/$RELEASE_VERSION" -f sha="$RELEASE_SHA" >/dev/null; then
127- echo 'Tag creation failed. If the tag already exists, inspect the earlier release before trying again.' >&2
131+ if ! gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/$RELEASE_VERSION" >/dev/null 2>&1; then
132+ if [[ "$CURSEFORGE_ONLY" == true ]]; then
133+ echo 'A CurseForge-only retry requires an existing release tag.' >&2
134+ exit 1
135+ fi
136+ gh api --method POST "repos/$GITHUB_REPOSITORY/git/refs" \
137+ -f ref="refs/tags/$RELEASE_VERSION" -f sha="$RELEASE_SHA" >/dev/null
138+ fi
139+ tag="$(gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/$RELEASE_VERSION" --jq '.object | "\(.type) \(.sha)"')"
140+ read -r tag_type tag_sha <<<"$tag"
141+ if [[ "$tag_type" == tag ]]; then
142+ tag="$(gh api "repos/$GITHUB_REPOSITORY/git/tags/$tag_sha" --jq '.object | "\(.type) \(.sha)"')"
143+ read -r tag_type tag_sha <<<"$tag"
144+ fi
145+ if [[ "$tag_type" != commit || "$tag_sha" != "$RELEASE_SHA" ]]; then
146+ echo 'The existing tag does not point to the verified release commit.' >&2
128147 exit 1
129148 fi
149+ echo "Verified tag $RELEASE_VERSION at $RELEASE_SHA"
130150
131151 - name : Publish on CurseForge
132152 if : inputs.confirm_live_publication
@@ -150,7 +170,7 @@ jobs:
150170 files : ${{ runner.temp }}/release-input/BaseGems-${{ inputs.release_version }}.jar
151171
152172 - name : Publish GitHub Release
153- if : inputs.confirm_live_publication
173+ if : inputs.confirm_live_publication && !inputs.curseforge_only
154174 working-directory : ${{ runner.temp }}/release-input
155175 env :
156176 GH_TOKEN : ${{ github.token }}
0 commit comments