Skip to content

Commit 10c1abd

Browse files
committedDec 27, 2024
Setup homebrew, maybe?
1 parent 68e01ed commit 10c1abd

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed
 

‎.github/workflows/release.yml

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

‎Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ cargo-dist-version = "0.27.0"
5151
# CI backends to support
5252
ci = ["github"]
5353
# The installers to generate for each app
54-
installers = []
54+
installers = ["homebrew"]
55+
tap = "jacktabscode/homebrew-tap"
56+
publish-jobs = ["homebrew"]
5557
# Target platforms to build apps for (Rust target-triple syntax)
5658
targets = [
5759
"aarch64-apple-darwin",

0 commit comments

Comments
 (0)