@@ -2,6 +2,11 @@ name: Weekly release (manual)
22
33on :
44 workflow_dispatch :
5+ inputs :
6+ hotfix_version :
7+ description : ' Version for an off-cycle release (e.g. 26.38.1). Publishes the current build under this version instead of the CalVer week.'
8+ required : false
9+ type : string
510
611permissions :
712 contents : read
@@ -27,12 +32,26 @@ jobs:
2732
2833 - name : Compute CalVer version
2934 id : compute
35+ env :
36+ HOTFIX_VERSION : ${{ github.event.inputs.hotfix_version }}
3037 run : |
31- VERSION=$(date -u +%g.%V)
38+ if [[ -n "$HOTFIX_VERSION" ]]; then
39+ if [[ ! "$HOTFIX_VERSION" =~ ^[0-9]{2}\.[0-9]{2}(\.[0-9]+)?$ ]]; then
40+ echo "::error::Invalid hotfix version format: $HOTFIX_VERSION"
41+ exit 1
42+ fi
43+ VERSION="$HOTFIX_VERSION"
44+ else
45+ VERSION=$(date -u +%g.%V)
46+ fi
3247 NEXT_VERSION=$(date -u -d "+7 days" +%g.%V)
3348 echo "version=$VERSION" >> "$GITHUB_OUTPUT"
3449 echo "next_version=$NEXT_VERSION" >> "$GITHUB_OUTPUT"
35- echo "Releasing $VERSION (next will be $NEXT_VERSION)"
50+ if [[ -n "$HOTFIX_VERSION" ]]; then
51+ echo "Releasing hotfix $VERSION (NEXT_RELEASE_VERSION left unchanged)"
52+ else
53+ echo "Releasing $VERSION (next will be $NEXT_VERSION)"
54+ fi
3655
3756 - name : Look up previous CalVer tag
3857 id : previous
4160 shell : flox activate -d flox/base -- bash -eo pipefail {0}
4261 run : |
4362 PREVIOUS_TAG=$(gh release list --json tagName \
44- --jq '[.[] | select(.tagName | test("^[0-9]+\\.[0-9]+$"))] | .[0].tagName // ""')
63+ --jq '[.[] | select(.tagName | test("^[0-9]+\\.[0-9]+(\\.[0-9]+)? $"))] | .[0].tagName // ""')
4564 echo "previous_tag=$PREVIOUS_TAG" >> "$GITHUB_OUTPUT"
4665 echo "Previous CalVer tag: ${PREVIOUS_TAG:-none}"
4766
@@ -198,20 +217,20 @@ jobs:
198217 exit 0
199218 fi
200219
220+ # A hotfix cut against a superseded release must not steal the "Latest"
221+ # badge from the newer release that is already published.
222+ IS_LATEST=true
223+ if [[ -n "$PREVIOUS_TAG" ]] \
224+ && [[ "$(printf '%s\n%s\n' "$VERSION" "$PREVIOUS_TAG" | sort -V | tail -n1)" != "$VERSION" ]]; then
225+ IS_LATEST=false
226+ fi
227+ echo "Marking $VERSION as latest: $IS_LATEST (previous tag: ${PREVIOUS_TAG:-none})"
228+
229+ ARGS=(--target "$GITHUB_SHA" --latest="$IS_LATEST" --title "$VERSION" --generate-notes)
201230 if [[ -n "$PREVIOUS_TAG" && "$PREVIOUS_TAG" != "$VERSION" ]]; then
202- gh release create "$VERSION" \
203- --target "$GITHUB_SHA" \
204- --latest \
205- --title "$VERSION" \
206- --generate-notes \
207- --notes-start-tag "$PREVIOUS_TAG"
208- else
209- gh release create "$VERSION" \
210- --target "$GITHUB_SHA" \
211- --latest \
212- --title "$VERSION" \
213- --generate-notes
231+ ARGS+=(--notes-start-tag "$PREVIOUS_TAG")
214232 fi
233+ gh release create "$VERSION" "${ARGS[@]}"
215234
216235 upload-r2 :
217236 needs : [prepare, pull-apk]
@@ -294,6 +313,7 @@ jobs:
294313 private-key : ${{ secrets.RELEASE_BOT_PRIVATE_KEY }}
295314
296315 - name : Set NEXT_RELEASE_VERSION repo variable
316+ if : ${{ github.event.inputs.hotfix_version == '' }}
297317 env :
298318 GH_TOKEN : ${{ steps.app-token.outputs.token }}
299319 NEXT_VERSION : ${{ needs.prepare.outputs.next_version }}
0 commit comments