|
| 1 | +name: Update Homebrew |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: 'Version to update (e.g., 0.2.0-beta.2)' |
| 8 | + required: true |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: write |
| 12 | + pull-requests: write |
| 13 | + |
| 14 | +jobs: |
| 15 | + update: |
| 16 | + name: Update Formula |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + with: |
| 21 | + ref: main |
| 22 | + |
| 23 | + - name: Download release assets |
| 24 | + run: | |
| 25 | + VERSION=${{ github.event.inputs.version }} |
| 26 | + mkdir -p artifacts |
| 27 | +
|
| 28 | + # Download all platform tarballs |
| 29 | + for target in aarch64-apple-darwin x86_64-apple-darwin aarch64-unknown-linux-gnu x86_64-unknown-linux-gnu; do |
| 30 | + curl -sL "https://github.com/GLINCKER/palrun/releases/download/v${VERSION}/palrun-${target}.tar.gz" \ |
| 31 | + -o "artifacts/palrun-${target}.tar.gz" |
| 32 | + done |
| 33 | +
|
| 34 | + - name: Update formula |
| 35 | + run: | |
| 36 | + VERSION=${{ github.event.inputs.version }} |
| 37 | +
|
| 38 | + SHA_DARWIN_ARM=$(sha256sum artifacts/palrun-aarch64-apple-darwin.tar.gz | cut -d' ' -f1) |
| 39 | + SHA_DARWIN_X64=$(sha256sum artifacts/palrun-x86_64-apple-darwin.tar.gz | cut -d' ' -f1) |
| 40 | + SHA_LINUX_ARM=$(sha256sum artifacts/palrun-aarch64-unknown-linux-gnu.tar.gz | cut -d' ' -f1) |
| 41 | + SHA_LINUX_X64=$(sha256sum artifacts/palrun-x86_64-unknown-linux-gnu.tar.gz | cut -d' ' -f1) |
| 42 | +
|
| 43 | + cat > HomebrewFormula/palrun.rb << EOF |
| 44 | + class Palrun < Formula |
| 45 | + desc "AI command palette for your terminal - discover and run project commands instantly" |
| 46 | + homepage "https://github.com/GLINCKER/palrun" |
| 47 | + version "${VERSION}" |
| 48 | + license "MIT" |
| 49 | +
|
| 50 | + on_macos do |
| 51 | + on_arm do |
| 52 | + url "https://github.com/GLINCKER/palrun/releases/download/v${VERSION}/palrun-aarch64-apple-darwin.tar.gz" |
| 53 | + sha256 "${SHA_DARWIN_ARM}" |
| 54 | + end |
| 55 | + on_intel do |
| 56 | + url "https://github.com/GLINCKER/palrun/releases/download/v${VERSION}/palrun-x86_64-apple-darwin.tar.gz" |
| 57 | + sha256 "${SHA_DARWIN_X64}" |
| 58 | + end |
| 59 | + end |
| 60 | +
|
| 61 | + on_linux do |
| 62 | + on_arm do |
| 63 | + url "https://github.com/GLINCKER/palrun/releases/download/v${VERSION}/palrun-aarch64-unknown-linux-gnu.tar.gz" |
| 64 | + sha256 "${SHA_LINUX_ARM}" |
| 65 | + end |
| 66 | + on_intel do |
| 67 | + url "https://github.com/GLINCKER/palrun/releases/download/v${VERSION}/palrun-x86_64-unknown-linux-gnu.tar.gz" |
| 68 | + sha256 "${SHA_LINUX_X64}" |
| 69 | + end |
| 70 | + end |
| 71 | +
|
| 72 | + def install |
| 73 | + bin.install "palrun" |
| 74 | + bin.install "pal" |
| 75 | + end |
| 76 | +
|
| 77 | + test do |
| 78 | + assert_match version.to_s, shell_output("#{bin}/palrun --version") |
| 79 | + end |
| 80 | + end |
| 81 | + EOF |
| 82 | +
|
| 83 | + - name: Create PR |
| 84 | + env: |
| 85 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 86 | + run: | |
| 87 | + VERSION=${{ github.event.inputs.version }} |
| 88 | + BRANCH="chore/homebrew-v${VERSION}" |
| 89 | +
|
| 90 | + git config user.name "github-actions[bot]" |
| 91 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 92 | +
|
| 93 | + # Force delete existing branch |
| 94 | + git push origin --delete "$BRANCH" 2>/dev/null || true |
| 95 | +
|
| 96 | + git checkout -b "$BRANCH" |
| 97 | + git add HomebrewFormula/palrun.rb |
| 98 | + git commit -m "chore(homebrew): update formula to v${VERSION}" |
| 99 | + git push -u origin "$BRANCH" --force |
| 100 | +
|
| 101 | + # Check if PR already exists |
| 102 | + EXISTING_PR=$(gh pr list --head "$BRANCH" --json number -q '.[0].number') |
| 103 | + if [ -n "$EXISTING_PR" ]; then |
| 104 | + echo "PR #$EXISTING_PR already exists" |
| 105 | + else |
| 106 | + gh pr create \ |
| 107 | + --title "chore(homebrew): update formula to v${VERSION}" \ |
| 108 | + --body "Auto-generated PR to update Homebrew formula for release v${VERSION}" \ |
| 109 | + --base main \ |
| 110 | + --head "$BRANCH" |
| 111 | + fi |
0 commit comments