Skip to content

Commit 97551d1

Browse files
committed
homebrew & all targets
1 parent 0aa25cf commit 97551d1

File tree

2 files changed

+55
-3
lines changed

2 files changed

+55
-3
lines changed

.github/workflows/release.yml

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

dist-workspace.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,14 @@ cargo-dist-version = "0.30.3"
88
# CI backends to support
99
ci = "github"
1010
# The installers to generate for each app
11-
installers = []
11+
installers = ["homebrew"]
1212
# Target platforms to build apps for (Rust target-triple syntax)
13-
targets = ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-pc-windows-msvc"]
13+
targets = ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "aarch64-pc-windows-msvc", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-pc-windows-msvc"]
14+
# A GitHub repo to push Homebrew formulas to
15+
tap = "raymondk/homebrew-icp-cli"
16+
# Publish jobs to run in CI
17+
publish-jobs = ["homebrew"]
18+
1419

1520
[dist.github-custom-runners]
1621
x86_64-unknown-linux-musl = "ubuntu-22.04-arm" # force dist build to use cargo-zigbuild on this target

0 commit comments

Comments
 (0)