|
69 | 69 | merge-multiple: true |
70 | 70 | - name: Publish to npm |
71 | 71 | run: ./scripts/publish.sh "${GITHUB_REF_NAME#v}" ./artifacts |
| 72 | + |
| 73 | + homebrew: |
| 74 | + name: Update Homebrew Tap |
| 75 | + needs: release |
| 76 | + runs-on: ubuntu-latest |
| 77 | + steps: |
| 78 | + - uses: actions/download-artifact@v4 |
| 79 | + with: |
| 80 | + path: artifacts |
| 81 | + merge-multiple: true |
| 82 | + |
| 83 | + - name: Compute SHA256 checksums |
| 84 | + id: checksums |
| 85 | + run: | |
| 86 | + echo "darwin_arm64=$(sha256sum artifacts/mux-darwin-arm64 | cut -d ' ' -f1)" >> "$GITHUB_OUTPUT" |
| 87 | + echo "darwin_x64=$(sha256sum artifacts/mux-darwin-x64 | cut -d ' ' -f1)" >> "$GITHUB_OUTPUT" |
| 88 | + echo "linux_arm64=$(sha256sum artifacts/mux-linux-arm64 | cut -d ' ' -f1)" >> "$GITHUB_OUTPUT" |
| 89 | + echo "linux_x64=$(sha256sum artifacts/mux-linux-x64 | cut -d ' ' -f1)" >> "$GITHUB_OUTPUT" |
| 90 | +
|
| 91 | + - name: Generate GitHub App token |
| 92 | + id: app-token |
| 93 | + uses: actions/create-github-app-token@v1 |
| 94 | + with: |
| 95 | + app-id: ${{ secrets.HOMEBREW_APP_ID }} |
| 96 | + private-key: ${{ secrets.HOMEBREW_APP_PRIVATE_KEY }} |
| 97 | + owner: muxinc |
| 98 | + repositories: homebrew-tap |
| 99 | + |
| 100 | + - uses: actions/checkout@v4 |
| 101 | + with: |
| 102 | + repository: muxinc/homebrew-tap |
| 103 | + token: ${{ steps.app-token.outputs.token }} |
| 104 | + |
| 105 | + - name: Generate formula |
| 106 | + run: | |
| 107 | + VERSION="${GITHUB_REF_NAME#v}" |
| 108 | + BASE_URL="https://github.com/muxinc/cli/releases/download/${GITHUB_REF_NAME}" |
| 109 | +
|
| 110 | + mkdir -p Formula |
| 111 | + cat > Formula/mux.rb << RUBY |
| 112 | + class Mux < Formula |
| 113 | + desc "The official Mux CLI" |
| 114 | + homepage "https://github.com/muxinc/cli" |
| 115 | + version "${VERSION}" |
| 116 | + license "MIT" |
| 117 | +
|
| 118 | + on_macos do |
| 119 | + if Hardware::CPU.arm? |
| 120 | + url "${BASE_URL}/mux-darwin-arm64" |
| 121 | + sha256 "${{ steps.checksums.outputs.darwin_arm64 }}" |
| 122 | + else |
| 123 | + url "${BASE_URL}/mux-darwin-x64" |
| 124 | + sha256 "${{ steps.checksums.outputs.darwin_x64 }}" |
| 125 | + end |
| 126 | + end |
| 127 | +
|
| 128 | + on_linux do |
| 129 | + if Hardware::CPU.arm? |
| 130 | + url "${BASE_URL}/mux-linux-arm64" |
| 131 | + sha256 "${{ steps.checksums.outputs.linux_arm64 }}" |
| 132 | + else |
| 133 | + url "${BASE_URL}/mux-linux-x64" |
| 134 | + sha256 "${{ steps.checksums.outputs.linux_x64 }}" |
| 135 | + end |
| 136 | + end |
| 137 | +
|
| 138 | + def install |
| 139 | + binary = Dir.glob("mux-*").first || "mux" |
| 140 | + bin.install binary => "mux" |
| 141 | + end |
| 142 | +
|
| 143 | + test do |
| 144 | + assert_match version.to_s, shell_output("#{bin}/mux --version") |
| 145 | + end |
| 146 | + end |
| 147 | + RUBY |
| 148 | +
|
| 149 | + - name: Commit and push formula |
| 150 | + run: | |
| 151 | + git config user.name "github-actions[bot]" |
| 152 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 153 | + git add Formula/mux.rb |
| 154 | + git commit -m "mux ${GITHUB_REF_NAME}" |
| 155 | + git push |
0 commit comments