Skip to content

Commit 4d823b9

Browse files
authored
CLI: enable homebrew installer (#1668)
The dist docs for for the `homebrew` installer indicate there are two parts to this: 1. create a "tap" repo and a github token for dist to use to manage it 2. configure dist here (with the token as a secret) The first piece will need to be done by someone else. This diff does the 2nd piece. The config for dist targets the extant `svix/homebrew-svix` repo, which appears to be where the tap lived previously. It's not clear if we'd need to empty that repo, reboot it, or anything else. Refs: - https://opensource.axo.dev/cargo-dist/book/installers/homebrew.html - https://github.com/svix/homebrew-svix
2 parents ce6ecb1 + 4126245 commit 4d823b9

File tree

2 files changed

+52
-2
lines changed

2 files changed

+52
-2
lines changed

.github/workflows/release.yml

+47-1
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,60 @@ jobs:
276276
277277
gh release edit "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --draft=false
278278
279+
publish-homebrew-formula:
280+
needs:
281+
- plan
282+
- host
283+
runs-on: "ubuntu-20.04"
284+
env:
285+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
286+
PLAN: ${{ needs.plan.outputs.val }}
287+
GITHUB_USER: "axo bot"
288+
GITHUB_EMAIL: "[email protected]"
289+
if: ${{ !fromJson(needs.plan.outputs.val).announcement_is_prerelease || fromJson(needs.plan.outputs.val).publish_prereleases }}
290+
steps:
291+
- uses: actions/checkout@v4
292+
with:
293+
repository: "svix/homebrew-svix"
294+
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
295+
# So we have access to the formula
296+
- name: Fetch homebrew formulae
297+
uses: actions/download-artifact@v4
298+
with:
299+
pattern: artifacts-*
300+
path: Formula/
301+
merge-multiple: true
302+
# This is extra complex because you can make your Formula name not match your app name
303+
# so we need to find releases with a *.rb file, and publish with that filename.
304+
- name: Commit formula files
305+
run: |
306+
git config --global user.name "${GITHUB_USER}"
307+
git config --global user.email "${GITHUB_EMAIL}"
308+
309+
for release in $(echo "$PLAN" | jq --compact-output '.releases[] | select([.artifacts[] | endswith(".rb")] | any)'); do
310+
filename=$(echo "$release" | jq '.artifacts[] | select(endswith(".rb"))' --raw-output)
311+
name=$(echo "$filename" | sed "s/\.rb$//")
312+
version=$(echo "$release" | jq .app_version --raw-output)
313+
314+
export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
315+
brew update
316+
# We avoid reformatting user-provided data such as the app description and homepage.
317+
brew style --except-cops FormulaAudit/Homepage,FormulaAudit/Desc,FormulaAuditStrict --fix "Formula/${filename}" || true
318+
319+
git add "Formula/${filename}"
320+
git commit -m "${name} ${version}"
321+
done
322+
git push
323+
279324
announce:
280325
needs:
281326
- plan
282327
- host
328+
- publish-homebrew-formula
283329
# use "always() && ..." to allow us to wait for all publish jobs while
284330
# still allowing individual publish jobs to skip themselves (for prereleases).
285331
# "host" however must run to completion, no skipping allowed!
286-
if: ${{ always() && needs.host.result == 'success' }}
332+
if: ${{ always() && needs.host.result == 'success' && (needs.publish-homebrew-formula.result == 'skipped' || needs.publish-homebrew-formula.result == 'success') }}
287333
runs-on: "ubuntu-20.04"
288334
env:
289335
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

dist-workspace.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ cargo-dist-version = "0.28.0"
88
# CI backends to support
99
ci = "github"
1010
# The installers to generate for each app
11-
installers = ["shell", "powershell", "msi"]
11+
installers = ["shell", "powershell", "homebrew", "msi"]
1212
# Target platforms to build apps for (Rust target-triple syntax)
1313
targets = ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-unknown-linux-musl", "x86_64-pc-windows-msvc"]
1414
# Whether dist should create a Github Release or use an existing draft
@@ -19,4 +19,8 @@ install-path = "~/.svix/bin"
1919
install-updater = true
2020
# Whether CI should trigger releases with dispatches instead of tag pushes
2121
dispatch-releases = true
22+
# A GitHub repo to push Homebrew formulas to
23+
tap = "svix/homebrew-svix"
24+
# Publish jobs to run in CI
25+
publish-jobs = ["homebrew"]
2226

0 commit comments

Comments
 (0)