`brew bump-cask-pr` forks homebrew-cask into the token owner's account, which requires a CLASSIC PAT with the `repo` scope. That scope cannot be narrowed: it grants write to every repository the owning account can reach, including this one. As an Actions secret it would be usable by anyone with push access here, because a pushed branch containing a workflow runs with repo secrets — a strict escalation for a channel that ships one DMG a month. Split the work so the token never becomes a CI secret: - CI (bump-homebrew.yml, now "Sync Homebrew Cask Reference") does the error-prone bookkeeping with GITHUB_TOKEN only: downloads the DMG, asserts it is notarized + stapled, computes the sha256, and opens an in-repo PR syncing desktopApp/packaging/homebrew/amethyst-nostr.rb. This makes it a third sibling of the amy/geode formula-sync workflows rather than a special case. - scripts/bump-homebrew-cask.sh does the upstream PR from a maintainer's shell, re-verifying sha256 and the notarization ticket against the live asset first, and refusing to submit if either fails. Verified against v1.13.1: the sha256 matches and it correctly refuses on the missing notarization ticket. Drop HOMEBREW_TOKEN from the secret inventory, and rewrite the two formula TODO(bootstrap) notes that proposed reintroducing it so a future homebrew-core submission follows the same local pattern.
170 lines
7.6 KiB
YAML
170 lines
7.6 KiB
YAML
name: Bump Homebrew Formula (amy CLI)
|
|
|
|
# Sibling of bump-homebrew.yml, but for a DIFFERENT Homebrew artifact:
|
|
# - bump-homebrew.yml -> Cask `amethyst-nostr` (the desktop GUI app / DMG)
|
|
# - this workflow -> Formula `amy` (the headless CLI jar bundle)
|
|
#
|
|
# What it does today: after a stable release, download the published
|
|
# `amy-<version>-jvm.tar.gz` bundle, compute its sha256, and open a PR that
|
|
# syncs `cli/packaging/homebrew/amy.rb`'s url + sha256 to that release. That is
|
|
# exactly the manual step the formula header calls out ("replace the version in
|
|
# the url and the sha256 with the values for the actual published release
|
|
# asset"), so keeping the in-repo reference formula accurate makes the eventual
|
|
# homebrew-core submission a copy-paste.
|
|
#
|
|
# What it does NOT do yet: open a PR against Homebrew/homebrew-core. `brew
|
|
# bump-formula-pr` can only bump a formula that already EXISTS in homebrew-core,
|
|
# and `amy` has never been submitted there — that first submission is a manual,
|
|
# human-reviewed new-formula PR (the one-time bootstrap). Once it lands, wire the
|
|
# auto-bump here (symmetric to the cask action in bump-homebrew.yml) — see the
|
|
# "TODO(bootstrap)" note at the bottom of this file.
|
|
|
|
# Trigger: after "Create Release Assets" succeeds for a tag push. NOT
|
|
# `release: types: [released]` — that event never fires, because the release is
|
|
# created by create-release.yml under GITHUB_TOKEN and GitHub suppresses
|
|
# workflow-triggering events for it. See the full note in bump-homebrew.yml.
|
|
on:
|
|
workflow_run:
|
|
workflows: ["Create Release Assets"]
|
|
types: [completed]
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag:
|
|
description: 'Release tag to sync (for manual recovery)'
|
|
required: true
|
|
type: string
|
|
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
# The "Report failure" step opens a [release-ops] issue via
|
|
# github.rest.issues.create, which needs issues:write.
|
|
issues: write
|
|
|
|
concurrency:
|
|
# Serialize per tag; do not cancel in-progress runs.
|
|
group: bump-homebrew-formula-${{ github.event.workflow_run.head_branch || inputs.tag }}
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
sync-formula:
|
|
# See bump-homebrew.yml for why these three conditions: successful, tag-push
|
|
# (not a dry-run dispatch), v-prefixed. Exact format enforced downstream.
|
|
if: >-
|
|
github.event_name == 'workflow_dispatch' ||
|
|
(github.event.workflow_run.conclusion == 'success' &&
|
|
github.event.workflow_run.event == 'push' &&
|
|
startsWith(github.event.workflow_run.head_branch, 'v'))
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 15
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v7
|
|
|
|
- name: Resolve release
|
|
id: rel
|
|
uses: ./.github/actions/resolve-release
|
|
with:
|
|
tag: ${{ github.event.workflow_run.head_branch || inputs.tag }}
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Re-assert stable release
|
|
uses: ./.github/actions/assert-stable-release
|
|
with:
|
|
tag: ${{ steps.rel.outputs.tag }}
|
|
is_prerelease: ${{ steps.rel.outputs.is_prerelease }}
|
|
is_draft: ${{ steps.rel.outputs.is_draft }}
|
|
|
|
- name: Download jvm bundle and compute sha256
|
|
id: asset
|
|
run: |
|
|
set -euo pipefail
|
|
TAG="${{ steps.rel.outputs.tag }}"
|
|
VER="${{ steps.rel.outputs.ver }}"
|
|
URL="https://github.com/${{ github.repository }}/releases/download/${TAG}/amy-${VER}-jvm.tar.gz"
|
|
echo "Fetching $URL"
|
|
# workflow_run fires only after every upload leg has finished, so the
|
|
# asset should already be there. Retry anyway for release-CDN
|
|
# propagation (mirrors the repo's push/pull retry ethos).
|
|
ok=0
|
|
for i in 1 2 3 4 5; do
|
|
if curl -fsSL -o amy-jvm.tar.gz "$URL"; then ok=1; break; fi
|
|
wait=$(( 2 ** i ))
|
|
echo "attempt $i failed; retrying in ${wait}s"
|
|
sleep "$wait"
|
|
done
|
|
[[ "$ok" == 1 ]] || { echo "::error::could not download $URL"; exit 1; }
|
|
test -s amy-jvm.tar.gz
|
|
SHA=$(shasum -a 256 amy-jvm.tar.gz | awk '{print $1}')
|
|
echo "url=$URL" >> "$GITHUB_OUTPUT"
|
|
echo "sha256=$SHA" >> "$GITHUB_OUTPUT"
|
|
echo "amy-${VER}-jvm.tar.gz -> $SHA"
|
|
|
|
- name: Update reference formula
|
|
run: |
|
|
set -euo pipefail
|
|
FORMULA=cli/packaging/homebrew/amy.rb
|
|
URL="${{ steps.asset.outputs.url }}"
|
|
SHA="${{ steps.asset.outputs.sha256 }}"
|
|
# Rewrite the two indented lines in the formula block. Anchoring on the
|
|
# 2-space indent avoids touching the header comment's example curl url.
|
|
sed -i -E "s|^( url ).*|\1\"${URL}\"|" "$FORMULA"
|
|
sed -i -E "s|^( sha256 ).*|\1\"${SHA}\"|" "$FORMULA"
|
|
echo "----- $FORMULA -----"
|
|
grep -E "^ (url|sha256) " "$FORMULA"
|
|
|
|
- name: Open or update the formula-sync PR
|
|
# peter-evans/create-pull-request is MIT-licensed CI-only tooling (not
|
|
# linked into any shipped artifact). It no-ops when there is no diff.
|
|
uses: peter-evans/create-pull-request@v8
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
base: main
|
|
branch: chore/bump-amy-formula-${{ steps.rel.outputs.tag }}
|
|
add-paths: cli/packaging/homebrew/amy.rb
|
|
commit-message: 'chore: sync amy Homebrew formula to ${{ steps.rel.outputs.tag }}'
|
|
title: 'chore: sync amy Homebrew formula to ${{ steps.rel.outputs.tag }}'
|
|
body: |
|
|
Auto-synced `cli/packaging/homebrew/amy.rb` to the
|
|
`${{ steps.rel.outputs.tag }}` release:
|
|
|
|
- `url` -> `${{ steps.asset.outputs.url }}`
|
|
- `sha256` -> `${{ steps.asset.outputs.sha256 }}`
|
|
|
|
Opened by `.github/workflows/bump-homebrew-formula.yml`. Merge to keep
|
|
the reference formula ready for the homebrew-core submission/bump.
|
|
|
|
# TODO(bootstrap): once `amy` is accepted into Homebrew/homebrew-core, add
|
|
# a LOCAL script mirroring scripts/bump-homebrew-cask.sh that runs `brew
|
|
# bump-formula-pr amy --url=<url> --sha256=<sha>` from a maintainer's
|
|
# machine. Do NOT wire that into CI: bump-formula-pr forks homebrew-core
|
|
# into the token owner's account, which needs a classic `repo`-scoped PAT,
|
|
# and that scope grants write to every repo the account can reach —
|
|
# including this one — to anyone with push access here. See
|
|
# BUILDING.md § Homebrew cask for the full reasoning.
|
|
|
|
- name: Report failure
|
|
if: failure()
|
|
uses: actions/github-script@v9
|
|
with:
|
|
script: |
|
|
const tag = context.payload.workflow_run?.head_branch || context.payload.inputs?.tag || 'unknown';
|
|
const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
|
|
await github.rest.issues.create({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
title: `[release-ops] bump-homebrew-formula failed for ${tag}`,
|
|
body: [
|
|
`amy Homebrew formula sync failed for release \`${tag}\`.`,
|
|
``,
|
|
`- Run: ${runUrl}`,
|
|
`- Channel: Homebrew Formula (\`amy\` CLI)`,
|
|
``,
|
|
`Recovery options:`,
|
|
`1. Re-run the workflow once the underlying issue is fixed`,
|
|
`2. Manually update \`cli/packaging/homebrew/amy.rb\` (url + sha256) from the release asset`,
|
|
`3. Check the release actually published \`amy-${tag.replace(/^v/, '')}-jvm.tar.gz\``
|
|
].join('\n'),
|
|
labels: ['release-ops', 'bug']
|
|
});
|