Skip to content

Commit 3208440

Browse files
committed
Enable homebrew in dist
1 parent 92c9d5e commit 3208440

File tree

2 files changed

+54
-3
lines changed

2 files changed

+54
-3
lines changed

.github/workflows/release.yml

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,14 +288,61 @@ jobs:
288288
289289
gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
290290
291+
publish-homebrew-formula:
292+
needs:
293+
- plan
294+
- host
295+
runs-on: "ubuntu-22.04"
296+
env:
297+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
298+
PLAN: ${{ needs.plan.outputs.val }}
299+
GITHUB_USER: "axo bot"
300+
GITHUB_EMAIL: "[email protected]"
301+
if: ${{ !fromJson(needs.plan.outputs.val).announcement_is_prerelease || fromJson(needs.plan.outputs.val).publish_prereleases }}
302+
steps:
303+
- uses: actions/checkout@v4
304+
with:
305+
persist-credentials: true
306+
repository: "sinelaw/homebrew-fresh"
307+
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
308+
# So we have access to the formula
309+
- name: Fetch homebrew formulae
310+
uses: actions/download-artifact@v4
311+
with:
312+
pattern: artifacts-*
313+
path: Formula/
314+
merge-multiple: true
315+
# This is extra complex because you can make your Formula name not match your app name
316+
# so we need to find releases with a *.rb file, and publish with that filename.
317+
- name: Commit formula files
318+
run: |
319+
git config --global user.name "${GITHUB_USER}"
320+
git config --global user.email "${GITHUB_EMAIL}"
321+
322+
for release in $(echo "$PLAN" | jq --compact-output '.releases[] | select([.artifacts[] | endswith(".rb")] | any)'); do
323+
filename=$(echo "$release" | jq '.artifacts[] | select(endswith(".rb"))' --raw-output)
324+
name=$(echo "$filename" | sed "s/\.rb$//")
325+
version=$(echo "$release" | jq .app_version --raw-output)
326+
327+
export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
328+
brew update
329+
# We avoid reformatting user-provided data such as the app description and homepage.
330+
brew style --except-cops FormulaAudit/Homepage,FormulaAudit/Desc,FormulaAuditStrict --fix "Formula/${filename}" || true
331+
332+
git add "Formula/${filename}"
333+
git commit -m "${name} ${version}"
334+
done
335+
git push
336+
291337
announce:
292338
needs:
293339
- plan
294340
- host
341+
- publish-homebrew-formula
295342
# use "always() && ..." to allow us to wait for all publish jobs while
296343
# still allowing individual publish jobs to skip themselves (for prereleases).
297344
# "host" however must run to completion, no skipping allowed!
298-
if: ${{ always() && needs.host.result == 'success' }}
345+
if: ${{ always() && needs.host.result == 'success' && (needs.publish-homebrew-formula.result == 'skipped' || needs.publish-homebrew-formula.result == 'success') }}
299346
runs-on: "ubuntu-22.04"
300347
env:
301348
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

dist-workspace.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ cargo-dist-version = "0.30.2"
88
# CI backends to support
99
ci = "github"
1010
# The installers to generate for each app
11-
installers = ["npm"]
11+
installers = ["npm", "homebrew"]
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-gnu", "x86_64-pc-windows-msvc"]
1414
# Path that installers should place binaries in
@@ -19,5 +19,9 @@ install-updater = false
1919
include = ["plugins/"]
2020
# A namespace to use when publishing this package to the npm registry
2121
npm-scope = "@fresh-editor"
22-
# Custom jobs to build .deb and .rpm packages (runs before host uploads artifacts)
22+
# Global artifacts jobs to run in CI
2323
global-artifacts-jobs = ["./linux-packages"]
24+
# A GitHub repo to push Homebrew formulas to
25+
tap = "sinelaw/homebrew-fresh"
26+
# Publish jobs to run in CI
27+
publish-jobs = ["homebrew"]

0 commit comments

Comments
 (0)