1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: Publish macOS binaries
# Builds native tarballs for both Apple Silicon and Intel Macs, for a Homebrew
# formula to point at. Cross-compiling x86_64-apple-darwin from the arm64
# runner works out of the box: Apple's SDK/linker support both targets from
# either host, so a single macOS runner builds both without extra toolchains.
on:
release:
types:
workflow_dispatch:
permissions:
contents: write
actions: write # required for the `gh workflow run` dispatch below
env:
CARGO_TERM_COLOR: always
jobs:
macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v7
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 #v2.9.1
- name: Add Rust targets
run: rustup target add aarch64-apple-darwin x86_64-apple-darwin
- name: Build and package both targets
run: |
version="$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')"
for target in aarch64-apple-darwin x86_64-apple-darwin; do
cargo build --release --locked --verbose --target "$target"
name="kinjo-${version}-${target}"
mkdir -p "$name/commands"
cp "target/${target}/release/kinjo" "$name/"
cp README.md LICENSE "$name/"
cp actions/*.toml "$name/commands/"
tar -czf "${name}.tar.gz" "$name"
done
- name: Upload packages to release
env:
GH_TOKEN: ${{ github.token }}
# github.event.release is only set for the `release` trigger; fall back
# to the checked-out ref when dispatched manually (see prepare-release.yml).
run: gh release upload "${{ github.event.release.tag_name || github.ref_name }}" kinjo-*.tar.gz --clobber
- name: Update the Homebrew tap
env:
GH_TOKEN: ${{ github.token }}
# The tap workflow cannot listen for this run's completion itself:
# this workflow is dispatched with GITHUB_TOKEN, whose activity emits
# no workflow-triggering events, so dispatch the update explicitly now
# that the tarballs the formula hashes are uploaded. A run from a
# branch rather than a release tag has nothing to sync.
run: |
tag="${{ github.event.release.tag_name || github.ref_name }}"
case "$tag" in
v*) gh workflow run update-homebrew-tap.yml --ref main -f tag="$tag" ;;
*) echo "Not a release tag ($tag); skipping the tap update." ;;
esac