From 35513651b9cddc08fe80019c3f701294ccf2bb9d Mon Sep 17 00:00:00 2001 From: diffwireauto <330573775+diffwireauto@users.noreply.github.com> Date: Sat, 28 Nov 2026 00:47:42 -0500 Subject: [PATCH] feat(#1247): manual macOS build that attaches to an existing release When the release run's macOS lane fails on our own workflow, a re-run uses the tag's copy of the files, so the fix can't reach that release. macos-manual.yml runs from main with a tag input: it checks that only .github/ and docs/ differ from the tag (so the zip is the tagged app), that the release exists and has no macOS zip yet, then calls macos-signed.yml unchanged and attaches the notarized zip. build.yml proves the check in a throwaway repo on every PR: it accepts the tag itself and a CI/docs change, and refuses an app or pubspec change and anything that isn't a real release tag. The test fails against a check that accepts everything. Co-Authored-By: Claude Opus 5.5 --- .github/scripts/macos-manual-check.sh | 26 ++++++++++ .github/workflows/build.yml | 42 +++++++++++++++ .github/workflows/macos-manual.yml | 74 +++++++++++++++++++++++++++ .github/workflows/macos-signed.yml | 3 +- 4 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 .github/scripts/macos-manual-check.sh create mode 100644 .github/workflows/macos-manual.yml diff --git a/.github/scripts/macos-manual-check.sh b/.github/scripts/macos-manual-check.sh new file mode 100644 index 00000000..0b8bcdc5 --- /dev/null +++ b/.github/scripts/macos-manual-check.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +# Decides whether a manual macOS build of HEAD may be attached to the release +# for (#1247). The zip has to be the tagged app, so only CI and docs may +# differ between the tag and HEAD. Anything else is refused, naming the files. +# +# usage: macos-manual-check.sh +set -eu + +tag="${1:?tag}" + +if ! printf '%s\n' "${tag}" | grep -Eqx 'v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?'; then + echo "::error::'${tag}' is not a release tag (vX.Y.Z or vX.Y.Z-rc.N)." + exit 1 +fi +if ! git rev-parse -q --verify "refs/tags/${tag}^{commit}" > /dev/null; then + echo "::error::Tag ${tag} does not exist in this checkout." + exit 1 +fi + +changed="$(git diff --name-only "refs/tags/${tag}" HEAD -- . ':!.github' ':!docs')" +if [ -n "${changed}" ]; then + echo "::error::Files outside .github/ and docs/ changed since ${tag}, so this would not build the tagged app:" + printf '%s\n' "${changed}" + exit 1 +fi +echo "Only CI and docs differ from ${tag}: this builds the tagged app." diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c41e4811..e3d890dd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -220,6 +220,48 @@ jobs: run: echo "docs-only diff; nothing to build" - uses: actions/checkout@v4 if: needs.classify.outputs.docs_only != 'true' + # macos-manual.yml needs secrets and can't run on a PR, so its check is + # proven here, in a throwaway repo (#1247). + - name: "Negative: the manual macOS check builds only the tagged app" + if: needs.classify.outputs.docs_only != 'true' + run: | + set -u + CHECK="${GITHUB_WORKSPACE}/.github/scripts/macos-manual-check.sh" + R="${RUNNER_TEMP}/macos-check" + mkdir -p "${R}" + cd "${R}" + git init -q + git config user.email ci@example.invalid + git config user.name ci + mkdir -p lib .github docs + echo a > lib/a.dart + echo c > .github/c.yml + echo d > docs/d.md + echo v > pubspec.yaml + git add -A + git commit -qm base + git tag v1.2.3 + bash "${CHECK}" v1.2.3 || { echo "::error::The tagged commit itself was refused."; exit 1; } + echo c2 > .github/c.yml + echo d2 > docs/d.md + git commit -qam ci + bash "${CHECK}" v1.2.3 || { echo "::error::A CI and docs change was refused."; exit 1; } + for f in lib/a.dart pubspec.yaml; do + echo changed > "${f}" + git commit -qam app + if bash "${CHECK}" v1.2.3 > /dev/null; then + echo "::error::A change to ${f} was accepted." + exit 1 + fi + git reset -q --hard HEAD~1 + done + for t in 1.2.3 v1.2 main v1.2.3-beta v9.9.9; do + if bash "${CHECK}" "${t}" > /dev/null; then + echo "::error::Tag '${t}' was accepted." + exit 1 + fi + done + echo "Accepted only CI and docs changes from a real tag, as required." - uses: subosito/flutter-action@v2 if: needs.classify.outputs.docs_only != 'true' with: diff --git a/.github/workflows/macos-manual.yml b/.github/workflows/macos-manual.yml new file mode 100644 index 00000000..7174cf96 --- /dev/null +++ b/.github/workflows/macos-manual.yml @@ -0,0 +1,74 @@ +name: macOS release (manual) + +# Builds, signs and notarizes the macOS app from main and attaches it to an +# existing release (#1247). For when the release run's macOS lane failed on a +# bug in our own workflow: a re-run uses the tag's copy of the files, so the +# fix has to come from main. An Apple-side hold doesn't need this: "Re-run +# failed jobs" on the release run finishes the same submission. +# +# Dispatch from main with the release tag. The check refuses to go on unless +# only .github/ and docs/ differ from the tag, so the zip is the tagged app. +# +# SECURITY: the build is macos-signed.yml, gated by the apple-macos +# Environment. NEVER add a `pull_request` trigger; see macos-signed.yml. + +on: + workflow_dispatch: + inputs: + tag: + description: "Release tag to attach the macOS zip to, e.g. v1.8.1" + required: true + +permissions: + contents: read + +concurrency: + group: macos-manual + cancel-in-progress: false + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Builds only the tagged app + env: + TAG: ${{ inputs.tag }} + run: bash .github/scripts/macos-manual-check.sh "${TAG}" + - name: The release exists and has no macOS zip yet + env: + GH_TOKEN: ${{ github.token }} + TAG: ${{ inputs.tag }} + run: | + set -eu + ASSETS="$(gh release view "${TAG}" --repo "${GITHUB_REPOSITORY}" --json assets --jq '.assets[].name')" || { + echo "::error::There is no release for ${TAG}." + exit 1 + } + if printf '%s\n' "${ASSETS}" | grep -qx 'offband-macos.zip'; then + echo "::error::The ${TAG} release already has offband-macos.zip. Delete it from the release first if it has to be replaced." + exit 1 + fi + echo "Release ${TAG} exists and has no macOS zip." + + macos: + needs: check + uses: ./.github/workflows/macos-signed.yml + secrets: inherit + + attach: + needs: [check, macos] + runs-on: ubuntu-latest + permissions: + contents: write # upload one asset to the existing release + steps: + - uses: actions/download-artifact@v4 + with: + name: release-macos + - name: Attach macOS asset + env: + GH_TOKEN: ${{ github.token }} + TAG: ${{ inputs.tag }} + run: gh release upload "${TAG}" offband-macos.zip --repo "${GITHUB_REPOSITORY}" diff --git a/.github/workflows/macos-signed.yml b/.github/workflows/macos-signed.yml index 2e95393f..3e3afaf6 100644 --- a/.github/workflows/macos-signed.yml +++ b/.github/workflows/macos-signed.yml @@ -2,7 +2,8 @@ name: macOS signed build # Builds the macOS app, signs it with the Developer ID Application identity, # notarizes it with Apple and staples the ticket, so it opens on any Mac with -# no Gatekeeper warning (#1109, epic #1107). Called by release-signed.yml. +# no Gatekeeper warning (#1109, epic #1107). Called by release-signed.yml, and +# by macos-manual.yml to attach a build from main to an existing release (#1247). # # Three jobs, so no Mac runner ever sits waiting on Apple's queue: # 1. build-sign-submit (Mac): build, sign, submit, keep the signed app.