Skip to content

Commit 90e7805

Browse files
committed
Homebrew: update formula to use pre-built binaries for mac
1 parent c4db6b4 commit 90e7805

2 files changed

Lines changed: 46 additions & 14 deletions

File tree

.github/workflows/release_github.yml

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -257,19 +257,32 @@ jobs:
257257
258258
echo "Updating Homebrew formula to version: $VERSION_WITHOUT_V"
259259
260-
# Download the source tarball to calculate SHA256
261-
TARBALL_URL="https://github.com/${{ github.repository }}/archive/refs/tags/${VERSION_WITHOUT_V}.tar.gz"
262-
263-
echo "Downloading tarball from: $TARBALL_URL"
264-
curl -sL "$TARBALL_URL" -o "/tmp/celq-${VERSION_WITHOUT_V}.tar.gz"
265-
266-
# Calculate SHA256
267-
SHA256=$(sha256sum "/tmp/celq-${VERSION_WITHOUT_V}.tar.gz" | awk '{print $1}')
268-
echo "Calculated SHA256: $SHA256"
260+
# Download and calculate SHA256 for source tarball
261+
SOURCE_URL="https://github.com/${{ github.repository }}/archive/refs/tags/${VERSION}.tar.gz"
262+
echo "Downloading source tarball from: $SOURCE_URL"
263+
curl -sL "$SOURCE_URL" -o "/tmp/celq-source.tar.gz"
264+
SHA256_SOURCE=$(sha256sum "/tmp/celq-source.tar.gz" | awk '{print $1}')
265+
echo "Source SHA256: $SHA256_SOURCE"
266+
267+
# Download and calculate SHA256 for ARM64 macOS binary
268+
ARM64_URL="https://github.com/${{ github.repository }}/releases/download/${VERSION}/celq-aarch64-apple-darwin.tar.gz"
269+
echo "Downloading ARM64 binary from: $ARM64_URL"
270+
curl -sL "$ARM64_URL" -o "/tmp/celq-arm64.tar.gz"
271+
SHA256_ARM64=$(sha256sum "/tmp/celq-arm64.tar.gz" | awk '{print $1}')
272+
echo "ARM64 SHA256: $SHA256_ARM64"
273+
274+
# Download and calculate SHA256 for x86_64 macOS binary
275+
X86_64_URL="https://github.com/${{ github.repository }}/releases/download/${VERSION}/celq-x86_64-apple-darwin.tar.gz"
276+
echo "Downloading x86_64 binary from: $X86_64_URL"
277+
curl -sL "$X86_64_URL" -o "/tmp/celq-x86_64.tar.gz"
278+
SHA256_X86_64=$(sha256sum "/tmp/celq-x86_64.tar.gz" | awk '{print $1}')
279+
echo "x86_64 SHA256: $SHA256_X86_64"
269280
270281
# Generate formula from template using sed
271282
sed -e "s/{{CELQ_VERSION}}/${VERSION_WITHOUT_V}/g" \
272-
-e "s/{{CELQ_SHA256}}/${SHA256}/g" \
283+
-e "s/{{CELQ_SHA256_SOURCE}}/${SHA256_SOURCE}/g" \
284+
-e "s/{{CELQ_SHA256_ARM64}}/${SHA256_ARM64}/g" \
285+
-e "s/{{CELQ_SHA256_X86_64}}/${SHA256_X86_64}/g" \
273286
celq-repo/brew/celq.rb > homebrew-tap/Formula/celq.rb
274287
275288
echo "Formula updated successfully"

brew/celq.rb

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,33 @@
11
class Celq < Formula
22
desc "A Common Expression Language (CEL) CLI Tool"
33
homepage "https://github.com/IvanIsCoding/celq"
4-
url "https://github.com/IvanIsCoding/celq/archive/refs/tags/{{CELQ_VERSION}}.tar.gz"
5-
sha256 "{{CELQ_SHA256}}"
4+
version "{{CELQ_VERSION}}"
65
license "MIT OR Apache-2.0"
76

8-
depends_on "rust" => :build
7+
if OS.mac?
8+
if Hardware::CPU.arm?
9+
url "https://github.com/IvanIsCoding/celq/releases/download/v{{CELQ_VERSION}}/celq-aarch64-apple-darwin.tar.gz"
10+
sha256 "{{CELQ_SHA256_ARM64}}"
11+
end
12+
if Hardware::CPU.intel?
13+
url "https://github.com/IvanIsCoding/celq/releases/download/v{{CELQ_VERSION}}/celq-x86_64-apple-darwin.tar.gz"
14+
sha256 "{{CELQ_SHA256_X86_64}}"
15+
end
16+
else
17+
# Fallback to source for Linux
18+
url "https://github.com/IvanIsCoding/celq/archive/refs/tags/{{CELQ_VERSION}}.tar.gz"
19+
sha256 "{{CELQ_SHA256_SOURCE}}"
20+
depends_on "rust" => :build
21+
end
922

1023
def install
11-
system "cargo", "install", "--locked", "--root", prefix, "--path", "."
24+
if OS.mac?
25+
# Install pre-built binary
26+
bin.install "celq"
27+
else
28+
# Build from source
29+
system "cargo", "install", "--locked", "--root", prefix, "--path", "."
30+
end
1231
end
1332

1433
test do

0 commit comments

Comments
 (0)