Skip to content

Commit e3af194

Browse files
vicentereigclaude
andcommitted
feat: multi-platform release builds with homebrew tap automation
- Build pre-compiled binaries for macOS (arm64/amd64) and Linux (arm64/amd64) - Add SHA256 checksums for all artifacts - Automate homebrew-tap formula updates on release - Remove local homebrew formula (now in vicentereig/homebrew-tap) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent d9a18ac commit e3af194

File tree

2 files changed

+153
-41
lines changed

2 files changed

+153
-41
lines changed

.github/workflows/release.yml

Lines changed: 153 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,39 +14,118 @@ permissions:
1414
contents: write
1515

1616
jobs:
17-
build:
18-
strategy:
19-
matrix:
20-
os: [ubuntu-latest, macos-latest]
21-
runs-on: ${{ matrix.os }}
17+
tests:
18+
name: Run tests
19+
runs-on: ubuntu-latest
2220
steps:
2321
- uses: actions/checkout@v4
2422
- uses: dtolnay/rust-toolchain@stable
2523
- name: Cargo test
2624
run: cargo test --locked
27-
- name: Cargo build
28-
run: cargo build --release --locked
29-
- name: Package binary
30-
id: package
31-
run: |
32-
BIN=plausible
33-
ARCHIVE="${BIN}-${{ matrix.os }}.tar.gz"
34-
tar -C target/release -czf "$ARCHIVE" "$BIN"
35-
echo "archive=$ARCHIVE" >> "$GITHUB_OUTPUT"
25+
26+
build-macos:
27+
name: Build macOS (${{ matrix.arch }})
28+
runs-on: macos-14
29+
needs: tests
30+
strategy:
31+
matrix:
32+
arch: [amd64, arm64]
33+
include:
34+
- arch: amd64
35+
target: x86_64-apple-darwin
36+
- arch: arm64
37+
target: aarch64-apple-darwin
38+
steps:
39+
- uses: actions/checkout@v4
40+
- uses: dtolnay/rust-toolchain@stable
41+
with:
42+
targets: ${{ matrix.target }}
43+
- name: Build
44+
run: |
45+
cargo build --release --locked --target ${{ matrix.target }}
46+
- name: Package
47+
run: |
48+
BINARY="plausible-darwin-${{ matrix.arch }}"
49+
cp target/${{ matrix.target }}/release/plausible "dist/${BINARY}" 2>/dev/null || {
50+
mkdir -p dist
51+
cp target/${{ matrix.target }}/release/plausible "dist/${BINARY}"
52+
}
53+
chmod +x "dist/${BINARY}"
54+
tar -C dist -czf "dist/${BINARY}.tar.gz" "${BINARY}"
55+
rm "dist/${BINARY}"
56+
(cd dist && shasum -a 256 "${BINARY}.tar.gz" > "${BINARY}.tar.gz.sha256")
57+
- name: Smoke test (arm64 only)
58+
if: matrix.arch == 'arm64'
59+
run: |
60+
tar -xzf dist/plausible-darwin-arm64.tar.gz -C dist
61+
./dist/plausible-darwin-arm64 --help >/dev/null
3662
- uses: actions/upload-artifact@v4
3763
with:
38-
name: ${{ matrix.os }}-bundle
39-
path: ${{ steps.package.outputs.archive }}
64+
name: macos-${{ matrix.arch }}
65+
path: dist/*
66+
67+
build-linux:
68+
name: Build Linux (${{ matrix.arch }})
69+
runs-on: ubuntu-latest
70+
needs: tests
71+
strategy:
72+
matrix:
73+
arch: [amd64, arm64]
74+
include:
75+
- arch: amd64
76+
target: x86_64-unknown-linux-gnu
77+
use_cross: false
78+
- arch: arm64
79+
target: aarch64-unknown-linux-gnu
80+
use_cross: true
81+
steps:
82+
- uses: actions/checkout@v4
83+
- uses: dtolnay/rust-toolchain@stable
84+
with:
85+
targets: ${{ matrix.target }}
86+
- name: Install cross
87+
if: matrix.use_cross
88+
run: cargo install cross --git https://github.com/cross-rs/cross
89+
- name: Build (native)
90+
if: "!matrix.use_cross"
91+
run: cargo build --release --locked --target ${{ matrix.target }}
92+
- name: Build (cross)
93+
if: matrix.use_cross
94+
run: cross build --release --locked --target ${{ matrix.target }}
95+
- name: Package
96+
run: |
97+
mkdir -p dist
98+
BINARY="plausible-linux-${{ matrix.arch }}"
99+
cp target/${{ matrix.target }}/release/plausible "dist/${BINARY}"
100+
chmod +x "dist/${BINARY}"
101+
tar -C dist -czf "dist/${BINARY}.tar.gz" "${BINARY}"
102+
rm "dist/${BINARY}"
103+
(cd dist && sha256sum "${BINARY}.tar.gz" > "${BINARY}.tar.gz.sha256")
104+
- name: Smoke test (amd64 only)
105+
if: matrix.arch == 'amd64'
106+
run: |
107+
tar -xzf dist/plausible-linux-amd64.tar.gz -C dist
108+
./dist/plausible-linux-amd64 --help >/dev/null
109+
- uses: actions/upload-artifact@v4
110+
with:
111+
name: linux-${{ matrix.arch }}
112+
path: dist/*
40113

41114
release:
42-
permissions:
43-
contents: write
44-
needs: build
115+
name: Create GitHub Release
45116
runs-on: ubuntu-latest
117+
needs:
118+
- build-macos
119+
- build-linux
46120
steps:
47121
- uses: actions/download-artifact@v4
48122
with:
49123
path: artifacts
124+
- name: Prepare release files
125+
run: |
126+
mkdir -p release-files
127+
find artifacts -type f -name '*.tar.gz' -exec mv {} release-files/ \;
128+
find artifacts -type f -name '*.sha256' -exec cat {} \; > release-files/checksums.txt
50129
- name: Resolve tag
51130
id: tag
52131
run: |
@@ -56,8 +135,60 @@ jobs:
56135
echo "value=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
57136
fi
58137
- name: Create GitHub Release
59-
if: ${{ steps.tag.outputs.value != '' }}
60-
uses: softprops/action-gh-release@v1
138+
if: steps.tag.outputs.value != ''
139+
uses: softprops/action-gh-release@v2
61140
with:
62-
files: artifacts/**/*
141+
files: |
142+
release-files/*.tar.gz
143+
release-files/*.sha256
144+
release-files/checksums.txt
63145
tag_name: ${{ steps.tag.outputs.value }}
146+
147+
update-homebrew:
148+
name: Update Homebrew formula
149+
runs-on: ubuntu-latest
150+
needs: release
151+
steps:
152+
- name: Resolve tag
153+
id: tag
154+
run: |
155+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
156+
echo "value=${{ inputs.tag }}" >> "$GITHUB_OUTPUT"
157+
else
158+
echo "value=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
159+
fi
160+
- name: Checkout tap repository
161+
uses: actions/checkout@v4
162+
with:
163+
repository: vicentereig/homebrew-tap
164+
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
165+
path: homebrew-tap
166+
- name: Update formula
167+
run: |
168+
TAG="${{ steps.tag.outputs.value }}"
169+
VERSION="${TAG#v}"
170+
BASE_URL="https://github.com/vicentereig/plausible-cli/releases/download/${TAG}"
171+
FORMULA="homebrew-tap/Formula/plausible.rb"
172+
173+
# Download SHA256 values from release
174+
DARWIN_AMD64=$(curl -sL "${BASE_URL}/plausible-darwin-amd64.tar.gz.sha256" | awk '{print $1}')
175+
DARWIN_ARM64=$(curl -sL "${BASE_URL}/plausible-darwin-arm64.tar.gz.sha256" | awk '{print $1}')
176+
LINUX_AMD64=$(curl -sL "${BASE_URL}/plausible-linux-amd64.tar.gz.sha256" | awk '{print $1}')
177+
LINUX_ARM64=$(curl -sL "${BASE_URL}/plausible-linux-arm64.tar.gz.sha256" | awk '{print $1}')
178+
179+
# Update version
180+
sed -i "s/version \".*\"/version \"${VERSION}\"/" "$FORMULA"
181+
182+
# Update SHA256 values
183+
sed -i "/darwin-amd64/,/sha256/{s/sha256 \"[^\"]*\"/sha256 \"${DARWIN_AMD64}\"/}" "$FORMULA"
184+
sed -i "/darwin-arm64/,/sha256/{s/sha256 \"[^\"]*\"/sha256 \"${DARWIN_ARM64}\"/}" "$FORMULA"
185+
sed -i "/linux-amd64/,/sha256/{s/sha256 \"[^\"]*\"/sha256 \"${LINUX_AMD64}\"/}" "$FORMULA"
186+
sed -i "/linux-arm64/,/sha256/{s/sha256 \"[^\"]*\"/sha256 \"${LINUX_ARM64}\"/}" "$FORMULA"
187+
- name: Commit and push
188+
working-directory: homebrew-tap
189+
run: |
190+
git config user.name "github-actions[bot]"
191+
git config user.email "github-actions[bot]@users.noreply.github.com"
192+
git add Formula/plausible.rb
193+
git diff --staged --quiet || git commit -m "Update plausible to ${{ steps.tag.outputs.value }}"
194+
git push

homebrew/Formula/plausible.rb

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)