Skip to content

Commit 113e5a0

Browse files
authored
Merge pull request #49 from muxinc/dj/add-homebrew
feat: add Homebrew tap support
2 parents 6689809 + 6e89dd0 commit 113e5a0

File tree

2 files changed

+119
-0
lines changed

2 files changed

+119
-0
lines changed

.github/workflows/release.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,87 @@ jobs:
6969
merge-multiple: true
7070
- name: Publish to npm
7171
run: ./scripts/publish.sh "${GITHUB_REF_NAME#v}" ./artifacts
72+
73+
homebrew:
74+
name: Update Homebrew Tap
75+
needs: release
76+
runs-on: ubuntu-latest
77+
steps:
78+
- uses: actions/download-artifact@v4
79+
with:
80+
path: artifacts
81+
merge-multiple: true
82+
83+
- name: Compute SHA256 checksums
84+
id: checksums
85+
run: |
86+
echo "darwin_arm64=$(sha256sum artifacts/mux-darwin-arm64 | cut -d ' ' -f1)" >> "$GITHUB_OUTPUT"
87+
echo "darwin_x64=$(sha256sum artifacts/mux-darwin-x64 | cut -d ' ' -f1)" >> "$GITHUB_OUTPUT"
88+
echo "linux_arm64=$(sha256sum artifacts/mux-linux-arm64 | cut -d ' ' -f1)" >> "$GITHUB_OUTPUT"
89+
echo "linux_x64=$(sha256sum artifacts/mux-linux-x64 | cut -d ' ' -f1)" >> "$GITHUB_OUTPUT"
90+
91+
- name: Generate GitHub App token
92+
id: app-token
93+
uses: actions/create-github-app-token@v1
94+
with:
95+
app-id: ${{ secrets.HOMEBREW_APP_ID }}
96+
private-key: ${{ secrets.HOMEBREW_APP_PRIVATE_KEY }}
97+
owner: muxinc
98+
repositories: homebrew-tap
99+
100+
- uses: actions/checkout@v4
101+
with:
102+
repository: muxinc/homebrew-tap
103+
token: ${{ steps.app-token.outputs.token }}
104+
105+
- name: Generate formula
106+
run: |
107+
VERSION="${GITHUB_REF_NAME#v}"
108+
BASE_URL="https://github.com/muxinc/cli/releases/download/${GITHUB_REF_NAME}"
109+
110+
mkdir -p Formula
111+
cat > Formula/mux.rb << RUBY
112+
class Mux < Formula
113+
desc "The official Mux CLI"
114+
homepage "https://github.com/muxinc/cli"
115+
version "${VERSION}"
116+
license "MIT"
117+
118+
on_macos do
119+
if Hardware::CPU.arm?
120+
url "${BASE_URL}/mux-darwin-arm64"
121+
sha256 "${{ steps.checksums.outputs.darwin_arm64 }}"
122+
else
123+
url "${BASE_URL}/mux-darwin-x64"
124+
sha256 "${{ steps.checksums.outputs.darwin_x64 }}"
125+
end
126+
end
127+
128+
on_linux do
129+
if Hardware::CPU.arm?
130+
url "${BASE_URL}/mux-linux-arm64"
131+
sha256 "${{ steps.checksums.outputs.linux_arm64 }}"
132+
else
133+
url "${BASE_URL}/mux-linux-x64"
134+
sha256 "${{ steps.checksums.outputs.linux_x64 }}"
135+
end
136+
end
137+
138+
def install
139+
binary = Dir.glob("mux-*").first || "mux"
140+
bin.install binary => "mux"
141+
end
142+
143+
test do
144+
assert_match version.to_s, shell_output("#{bin}/mux --version")
145+
end
146+
end
147+
RUBY
148+
149+
- name: Commit and push formula
150+
run: |
151+
git config user.name "github-actions[bot]"
152+
git config user.email "github-actions[bot]@users.noreply.github.com"
153+
git add Formula/mux.rb
154+
git commit -m "mux ${GITHUB_REF_NAME}"
155+
git push

Formula/mux.rb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
class Mux < Formula
2+
desc "The official Mux CLI"
3+
homepage "https://github.com/muxinc/cli"
4+
version "0.0.0"
5+
license "MIT"
6+
7+
on_macos do
8+
if Hardware::CPU.arm?
9+
url "https://github.com/muxinc/cli/releases/download/v#{version}/mux-darwin-arm64"
10+
sha256 "PLACEHOLDER"
11+
else
12+
url "https://github.com/muxinc/cli/releases/download/v#{version}/mux-darwin-x64"
13+
sha256 "PLACEHOLDER"
14+
end
15+
end
16+
17+
on_linux do
18+
if Hardware::CPU.arm?
19+
url "https://github.com/muxinc/cli/releases/download/v#{version}/mux-linux-arm64"
20+
sha256 "PLACEHOLDER"
21+
else
22+
url "https://github.com/muxinc/cli/releases/download/v#{version}/mux-linux-x64"
23+
sha256 "PLACEHOLDER"
24+
end
25+
end
26+
27+
def install
28+
binary = Dir.glob("mux-*").first || "mux"
29+
bin.install binary => "mux"
30+
end
31+
32+
test do
33+
assert_match version.to_s, shell_output("#{bin}/mux --version")
34+
end
35+
end

0 commit comments

Comments
 (0)