Skip to content

Commit f016333

Browse files
therealalephclaude
andcommitted
ci(release): add workflow_dispatch with version input
The original `on: push: tags: 'v*'` trigger is the right primary path — a new tag = a new release = a fresh workflow run. But it has a failure mode: if one matrix job fails (e.g. mipsel-softfloat is tier-3 and occasionally regresses) and we push a fix to main, we can't move the immutable tag (tag protection rule), so the original artifact stays missing from that release forever. `workflow_dispatch` with a `version` input lets us re-run the workflow from main against an existing release tag: gh workflow run release.yml --ref main -f version=1.4.0 The build matrix runs against the current main commit (which has the fix), and the release-upload step uploads to the existing v1.4.0 release page with the same filename pattern, alongside the artifacts that succeeded on the original push. Three call sites had to learn the new path: the macOS .app bundle build, the Android APK rename step, and the Telegram caption builder. All three previously did `VER="${GITHUB_REF#refs/tags/v}"`, which on a workflow_dispatch from main produces "heads/main" — the new two-line `VER="${{ inputs.version || github.ref_name }}"; VER="${VER#v}"` pattern handles both: tag pushes get the bare version from `github.ref_name` ("v1.4.0" → "1.4.0"), workflow_dispatch gets it from the explicit input. The release job's `softprops/action-gh-release@v2` step also needed an explicit `tag_name` — without it the action defaults to `github.ref`, which on workflow_dispatch is the dispatch ref (`refs/heads/main`) and would try to create a release named "main". Now it's: tag_name: ${{ inputs.version && format('v{0}', inputs.version) || github.ref_name }} Pair with `gh variable set TELEGRAM_NOTIFY_ENABLED --body false` before dispatch when the re-run is for the same version (no new content for the channel to see) — the Telegram job is already gated on that variable, no per-run flag needed. Used right now to publish the mhrv-rs-openwrt-mipsel-softfloat artifact that failed on v1.4.0's original push, after commit 6a0d45d fixed the underlying compile error. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 6a0d45d commit f016333

1 file changed

Lines changed: 33 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@ on:
44
push:
55
tags:
66
- 'v*'
7+
# Manual re-trigger for the case where one matrix job (e.g. mipsel-softfloat)
8+
# failed on the original tag push and we've since pushed the build fix to
9+
# main but can't force-move the immutable tag (tag protection rule). Run
10+
# this workflow manually with `version` set to the existing release tag —
11+
# the build matrix runs against the current main, artifacts are uploaded
12+
# to the matching release page, and the release-notes step is a no-op
13+
# (release already exists). Pair with `gh variable set
14+
# TELEGRAM_NOTIFY_ENABLED --body false` before dispatch if you don't want
15+
# the channel re-pinged for what's effectively the same release.
16+
workflow_dispatch:
17+
inputs:
18+
version:
19+
description: 'Existing release tag to upload to (without the leading v). Example: 1.4.0'
20+
required: true
21+
type: string
722

823
permissions:
924
contents: write
@@ -277,7 +292,12 @@ jobs:
277292
- name: Build macOS .app bundle
278293
if: runner.os == 'macOS'
279294
run: |
280-
VER="${GITHUB_REF#refs/tags/v}"
295+
# Tag push: $GITHUB_REF == "refs/tags/v1.4.0", strip "refs/tags/v".
296+
# workflow_dispatch: inputs.version comes in as e.g. "1.4.0".
297+
# Fall back to ref_name (the bare branch/tag name) and strip a
298+
# possible leading "v" so both paths produce the bare version.
299+
VER="${{ inputs.version || github.ref_name }}"
300+
VER="${VER#v}"
281301
./assets/macos/build-app.sh dist/mhrv-rs-ui "$VER" dist
282302
# Make a clean zip of just the .app for the release
283303
cd dist
@@ -378,7 +398,8 @@ jobs:
378398
- name: Rename APKs with version
379399
working-directory: android
380400
run: |
381-
VER="${GITHUB_REF#refs/tags/v}"
401+
VER="${{ inputs.version || github.ref_name }}"
402+
VER="${VER#v}"
382403
mkdir -p ../dist
383404
384405
# With splits.abi enabled in build.gradle.kts (issue #136), AGP
@@ -455,6 +476,14 @@ jobs:
455476
- name: Release
456477
uses: softprops/action-gh-release@v2
457478
with:
479+
# On tag push, action-gh-release defaults tag_name to the
480+
# current ref. On workflow_dispatch the ref is `main` (or
481+
# whichever branch we dispatched from), which would create a
482+
# bogus release named "main"; force the tag explicitly so
483+
# artifacts upload to the existing release identified by
484+
# `inputs.version`. The leading `v` is preserved (release
485+
# tags are `v1.4.0`, not `1.4.0`).
486+
tag_name: ${{ inputs.version && format('v{0}', inputs.version) || github.ref_name }}
458487
files: dist/*
459488
generate_release_notes: true
460489

@@ -509,7 +538,8 @@ jobs:
509538
# 26. Python stdlib has no such wart.
510539
run: |
511540
set -euo pipefail
512-
VER="${GITHUB_REF#refs/tags/v}"
541+
VER="${{ inputs.version || github.ref_name }}"
542+
VER="${VER#v}"
513543
APK="apk/mhrv-rs-android-universal-v${VER}.apk"
514544
515545
if [ -z "${BOT_TOKEN:-}" ] || [ -z "${CHAT_ID:-}" ]; then

0 commit comments

Comments
 (0)