Skip to content

Commit 9c04eae

Browse files
committed
chore: wip
1 parent 1134ce1 commit 9c04eae

File tree

4 files changed

+163
-0
lines changed

4 files changed

+163
-0
lines changed

.github/homebrew/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Stacks Homebrew Tap
2+
3+
This repository contains the Homebrew formulae for Stacks packages.
4+
5+
## Installation
6+
7+
```bash
8+
# Add the tap
9+
brew tap stacksjs/tap
10+
11+
# Install stacks
12+
brew install stacks
13+
```
14+
15+
This will install the `stacks` CLI tool and all its aliases (`stx`, `buddy`, `bud`).
16+
17+
## Usage
18+
19+
After installation, you can use the Stacks CLI:
20+
21+
```bash
22+
# Show version
23+
stacks --version
24+
25+
# Get help
26+
stacks --help
27+
28+
# Or use any of the aliases
29+
stx --help
30+
buddy --help
31+
bud --help
32+
```
33+
34+
## License
35+
36+
MIT

.github/homebrew/stacks.rb

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
class Stacks < Formula
2+
desc "Meet Buddy. The Stacks runtime."
3+
homepage "https://github.com/stacksjs/stacks"
4+
version "0.70.11"
5+
license "MIT"
6+
7+
on_macos do
8+
if Hardware::CPU.arm?
9+
url "https://github.com/stacksjs/stacks/releases/download/v#{version}/buddy-darwin-arm64"
10+
sha256 "PLACEHOLDER_SHA_ARM64"
11+
else
12+
url "https://github.com/stacksjs/stacks/releases/download/v#{version}/buddy-darwin-x64"
13+
sha256 "PLACEHOLDER_SHA_X64"
14+
end
15+
end
16+
17+
on_linux do
18+
if Hardware::CPU.arm?
19+
url "https://github.com/stacksjs/stacks/releases/download/v#{version}/buddy-linux-arm64"
20+
sha256 "PLACEHOLDER_SHA_LINUX_ARM64"
21+
else
22+
url "https://github.com/stacksjs/stacks/releases/download/v#{version}/buddy-linux-x64"
23+
sha256 "PLACEHOLDER_SHA_LINUX_X64"
24+
end
25+
end
26+
27+
def install
28+
binary_name = Hardware::CPU.arm? ?
29+
(OS.mac? ? "buddy-darwin-arm64" : "buddy-linux-arm64") :
30+
(OS.mac? ? "buddy-darwin-x64" : "buddy-linux-x64")
31+
32+
bin.install binary_name => "stacks"
33+
bin.install_symlink "stacks" => "stx"
34+
bin.install_symlink "stacks" => "buddy"
35+
bin.install_symlink "stacks" => "bud"
36+
end
37+
38+
test do
39+
assert_match "Stacks", shell_output("#{bin}/stacks --version")
40+
end
41+
end
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
set -e
3+
4+
VERSION=$1
5+
6+
if [ -z "$VERSION" ]; then
7+
echo "Usage: $0 <version>"
8+
exit 1
9+
fi
10+
11+
VERSION_NUMBER=${VERSION#v} # Remove 'v' prefix if present
12+
FORMULA_FILE=".github/homebrew/stacks.rb"
13+
14+
# Download the binaries to calculate their SHA256
15+
mkdir -p .github/temp
16+
cd .github/temp
17+
18+
curl -sL "https://github.com/stacksjs/stacks/releases/download/$VERSION/buddy-darwin-arm64" -o buddy-darwin-arm64
19+
curl -sL "https://github.com/stacksjs/stacks/releases/download/$VERSION/buddy-darwin-x64" -o buddy-darwin-x64
20+
curl -sL "https://github.com/stacksjs/stacks/releases/download/$VERSION/buddy-linux-arm64" -o buddy-linux-arm64
21+
curl -sL "https://github.com/stacksjs/stacks/releases/download/$VERSION/buddy-linux-x64" -o buddy-linux-x64
22+
23+
# Calculate SHA256 checksums
24+
SHA_ARM64=$(shasum -a 256 buddy-darwin-arm64 | cut -d ' ' -f 1)
25+
SHA_X64=$(shasum -a 256 buddy-darwin-x64 | cut -d ' ' -f 1)
26+
SHA_LINUX_ARM64=$(shasum -a 256 buddy-linux-arm64 | cut -d ' ' -f 1)
27+
SHA_LINUX_X64=$(shasum -a 256 buddy-linux-x64 | cut -d ' ' -f 1)
28+
29+
cd ../..
30+
31+
# Update the formula
32+
sed -i '' "s/version \".*\"/version \"$VERSION_NUMBER\"/" $FORMULA_FILE
33+
sed -i '' "s/PLACEHOLDER_SHA_ARM64/$SHA_ARM64/" $FORMULA_FILE
34+
sed -i '' "s/PLACEHOLDER_SHA_X64/$SHA_X64/" $FORMULA_FILE
35+
sed -i '' "s/PLACEHOLDER_SHA_LINUX_ARM64/$SHA_LINUX_ARM64/" $FORMULA_FILE
36+
sed -i '' "s/PLACEHOLDER_SHA_LINUX_X64/$SHA_LINUX_X64/" $FORMULA_FILE
37+
38+
echo "Updated Homebrew formula with version $VERSION_NUMBER and SHA256 checksums"
39+
40+
# Clean up
41+
rm -rf .github/temp

.github/workflows/homebrew.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: CI
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
update-homebrew:
9+
runs-on: macos-latest
10+
steps:
11+
- name: Checkout Repository
12+
uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
15+
16+
- name: Update Homebrew Formula
17+
run: |
18+
.github/scripts/update-homebrew-formula.sh ${{ github.event.release.tag_name }}
19+
20+
- name: Set up Git User
21+
run: |
22+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
23+
git config --local user.name "github-actions[bot]"
24+
25+
- name: Create Homebrew Tap PR
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
run: |
29+
# Check if homebrew tap repo exists, if not create it
30+
if ! git ls-remote --exit-code https://github.com/stacksjs/homebrew-tap; then
31+
gh repo create stacksjs/homebrew-tap --public --description "Homebrew tap for Stacks packages"
32+
fi
33+
34+
# Clone the tap repo
35+
git clone https://x-access-token:${GITHUB_TOKEN}@github.com/stacksjs/homebrew-tap.git
36+
37+
# Copy the formula to the tap repo
38+
mkdir -p homebrew-tap/Formula
39+
cp .github/homebrew/stacks.rb homebrew-tap/Formula/
40+
41+
# Push the changes to the tap repo
42+
cd homebrew-tap
43+
git add Formula/stacks.rb
44+
git commit -m "chore: update formula to ${{ github.event.release.tag_name }}"
45+
git push

0 commit comments

Comments
 (0)