Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions .github/workflows/homebrew.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Publish to Homebrew

on:
release:
types: [published]

jobs:
homebrew:
name: Update Homebrew Formula
runs-on: ubuntu-latest
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
steps:
- name: Download release binaries
run: |
TAG=${{ github.event.release.tag_name }}
for PLATFORM in darwin-amd64 darwin-arm64 linux-amd64 linux-arm64; do
curl -fL -o "aperiodic-${PLATFORM}" \
"https://github.com/aperiodic-io/cli/releases/download/${TAG}/aperiodic-${PLATFORM}"
done

- name: Compute SHA256 checksums
id: sha256
run: |
echo "darwin_amd64=$(sha256sum aperiodic-darwin-amd64 | awk '{print $1}')" >> $GITHUB_OUTPUT
echo "darwin_arm64=$(sha256sum aperiodic-darwin-arm64 | awk '{print $1}')" >> $GITHUB_OUTPUT
echo "linux_amd64=$(sha256sum aperiodic-linux-amd64 | awk '{print $1}')" >> $GITHUB_OUTPUT
echo "linux_arm64=$(sha256sum aperiodic-linux-arm64 | awk '{print $1}')" >> $GITHUB_OUTPUT

- name: Checkout Homebrew tap
uses: actions/checkout@v4
with:
repository: aperiodic-io/homebrew-tap
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
path: homebrew-tap

- name: Update formula
run: |
TAG=${{ github.event.release.tag_name }}
VERSION=${TAG#v}
mkdir -p homebrew-tap/Formula
cat > homebrew-tap/Formula/aperiodic.rb << EOF
class Aperiodic < Formula
desc "Aperiodic CLI"
homepage "https://github.com/aperiodic-io/cli"
version "${VERSION}"
license "MIT"

on_macos do
on_arm do
url "https://github.com/aperiodic-io/cli/releases/download/${TAG}/aperiodic-darwin-arm64"
sha256 "${{ steps.sha256.outputs.darwin_arm64 }}"
end
on_intel do
url "https://github.com/aperiodic-io/cli/releases/download/${TAG}/aperiodic-darwin-amd64"
sha256 "${{ steps.sha256.outputs.darwin_amd64 }}"
end
end

on_linux do
on_arm do
url "https://github.com/aperiodic-io/cli/releases/download/${TAG}/aperiodic-linux-arm64"
sha256 "${{ steps.sha256.outputs.linux_arm64 }}"
end
on_intel do
url "https://github.com/aperiodic-io/cli/releases/download/${TAG}/aperiodic-linux-amd64"
sha256 "${{ steps.sha256.outputs.linux_amd64 }}"
end
end

def install
bin.install Dir["aperiodic-*"].first => "aperiodic"
end

test do
system "#{bin}/aperiodic", "--version"
end
end
EOF

- name: Commit and push formula
run: |
cd homebrew-tap
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/aperiodic.rb
git diff --cached --quiet || git commit -m "chore: update aperiodic to ${{ github.event.release.tag_name }}"
git push
Loading