mirror of
https://github.com/therealaleph/MasterHttpRelayVPN-RUST.git
synced 2026-05-17 21:24:48 +03:00
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 febeeca fixed the
underlying compile error.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,21 @@ on:
|
|||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- 'v*'
|
||||||
|
# Manual re-trigger for the case where one matrix job (e.g. mipsel-softfloat)
|
||||||
|
# failed on the original tag push and we've since pushed the build fix to
|
||||||
|
# main but can't force-move the immutable tag (tag protection rule). Run
|
||||||
|
# this workflow manually with `version` set to the existing release tag —
|
||||||
|
# the build matrix runs against the current main, artifacts are uploaded
|
||||||
|
# to the matching release page, and the release-notes step is a no-op
|
||||||
|
# (release already exists). Pair with `gh variable set
|
||||||
|
# TELEGRAM_NOTIFY_ENABLED --body false` before dispatch if you don't want
|
||||||
|
# the channel re-pinged for what's effectively the same release.
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
version:
|
||||||
|
description: 'Existing release tag to upload to (without the leading v). Example: 1.4.0'
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
@@ -277,7 +292,12 @@ jobs:
|
|||||||
- name: Build macOS .app bundle
|
- name: Build macOS .app bundle
|
||||||
if: runner.os == 'macOS'
|
if: runner.os == 'macOS'
|
||||||
run: |
|
run: |
|
||||||
VER="${GITHUB_REF#refs/tags/v}"
|
# Tag push: $GITHUB_REF == "refs/tags/v1.4.0", strip "refs/tags/v".
|
||||||
|
# workflow_dispatch: inputs.version comes in as e.g. "1.4.0".
|
||||||
|
# Fall back to ref_name (the bare branch/tag name) and strip a
|
||||||
|
# possible leading "v" so both paths produce the bare version.
|
||||||
|
VER="${{ inputs.version || github.ref_name }}"
|
||||||
|
VER="${VER#v}"
|
||||||
./assets/macos/build-app.sh dist/mhrv-rs-ui "$VER" dist
|
./assets/macos/build-app.sh dist/mhrv-rs-ui "$VER" dist
|
||||||
# Make a clean zip of just the .app for the release
|
# Make a clean zip of just the .app for the release
|
||||||
cd dist
|
cd dist
|
||||||
@@ -378,7 +398,8 @@ jobs:
|
|||||||
- name: Rename APKs with version
|
- name: Rename APKs with version
|
||||||
working-directory: android
|
working-directory: android
|
||||||
run: |
|
run: |
|
||||||
VER="${GITHUB_REF#refs/tags/v}"
|
VER="${{ inputs.version || github.ref_name }}"
|
||||||
|
VER="${VER#v}"
|
||||||
mkdir -p ../dist
|
mkdir -p ../dist
|
||||||
|
|
||||||
# With splits.abi enabled in build.gradle.kts (issue #136), AGP
|
# With splits.abi enabled in build.gradle.kts (issue #136), AGP
|
||||||
@@ -455,6 +476,14 @@ jobs:
|
|||||||
- name: Release
|
- name: Release
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
|
# On tag push, action-gh-release defaults tag_name to the
|
||||||
|
# current ref. On workflow_dispatch the ref is `main` (or
|
||||||
|
# whichever branch we dispatched from), which would create a
|
||||||
|
# bogus release named "main"; force the tag explicitly so
|
||||||
|
# artifacts upload to the existing release identified by
|
||||||
|
# `inputs.version`. The leading `v` is preserved (release
|
||||||
|
# tags are `v1.4.0`, not `1.4.0`).
|
||||||
|
tag_name: ${{ inputs.version && format('v{0}', inputs.version) || github.ref_name }}
|
||||||
files: dist/*
|
files: dist/*
|
||||||
generate_release_notes: true
|
generate_release_notes: true
|
||||||
|
|
||||||
@@ -509,7 +538,8 @@ jobs:
|
|||||||
# 26. Python stdlib has no such wart.
|
# 26. Python stdlib has no such wart.
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
VER="${GITHUB_REF#refs/tags/v}"
|
VER="${{ inputs.version || github.ref_name }}"
|
||||||
|
VER="${VER#v}"
|
||||||
APK="apk/mhrv-rs-android-universal-v${VER}.apk"
|
APK="apk/mhrv-rs-android-universal-v${VER}.apk"
|
||||||
|
|
||||||
if [ -z "${BOT_TOKEN:-}" ] || [ -z "${CHAT_ID:-}" ]; then
|
if [ -z "${BOT_TOKEN:-}" ] || [ -z "${CHAT_ID:-}" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user