|
42 | 42 | run: npm publish --access public |
43 | 43 | env: |
44 | 44 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 45 | + |
| 46 | + update-homebrew: |
| 47 | + name: Update Homebrew Formula |
| 48 | + needs: publish |
| 49 | + runs-on: ubuntu-latest |
| 50 | + permissions: |
| 51 | + contents: read |
| 52 | + |
| 53 | + steps: |
| 54 | + - name: Wait for npm registry propagation |
| 55 | + run: sleep 30 |
| 56 | + |
| 57 | + - name: Get version from tag |
| 58 | + id: version |
| 59 | + run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" |
| 60 | + |
| 61 | + - name: Download tarball and compute SHA |
| 62 | + id: sha |
| 63 | + run: | |
| 64 | + URL="https://registry.npmjs.org/@sunilp-org/jam-cli/-/jam-cli-${{ steps.version.outputs.version }}.tgz" |
| 65 | + # Retry up to 3 times in case registry hasn't propagated yet |
| 66 | + for i in 1 2 3; do |
| 67 | + HTTP_CODE=$(curl -s -o /tmp/jam.tgz -w "%{http_code}" "$URL") |
| 68 | + if [ "$HTTP_CODE" = "200" ]; then break; fi |
| 69 | + echo "Attempt $i: got $HTTP_CODE, retrying in 15s..." |
| 70 | + sleep 15 |
| 71 | + done |
| 72 | + SHA=$(sha256sum /tmp/jam.tgz | awk '{print $1}') |
| 73 | + echo "sha256=$SHA" >> "$GITHUB_OUTPUT" |
| 74 | + echo "url=$URL" >> "$GITHUB_OUTPUT" |
| 75 | +
|
| 76 | + - name: Checkout homebrew-tap |
| 77 | + uses: actions/checkout@v5 |
| 78 | + with: |
| 79 | + repository: sunilp/homebrew-tap |
| 80 | + token: ${{ secrets.HOMEBREW_TAP_TOKEN }} |
| 81 | + path: homebrew-tap |
| 82 | + |
| 83 | + - name: Update formula |
| 84 | + run: | |
| 85 | + cat > homebrew-tap/Formula/jam-cli.rb << 'FORMULA' |
| 86 | + class JamCli < Formula |
| 87 | + desc "Developer-first AI CLI for cross-language code intelligence" |
| 88 | + homepage "https://jam.sunilprakash.com" |
| 89 | + url "${{ steps.sha.outputs.url }}" |
| 90 | + sha256 "${{ steps.sha.outputs.sha256 }}" |
| 91 | + license "MIT" |
| 92 | +
|
| 93 | + depends_on "node@20" |
| 94 | +
|
| 95 | + def install |
| 96 | + system "npm", "install", *std_npm_args |
| 97 | + bin.install_symlink Dir["#{libexec}/bin/*"] |
| 98 | + end |
| 99 | +
|
| 100 | + test do |
| 101 | + assert_match version.to_s, shell_output("#{bin}/jam --version") |
| 102 | + end |
| 103 | + end |
| 104 | + FORMULA |
| 105 | +
|
| 106 | + - name: Push formula update |
| 107 | + working-directory: homebrew-tap |
| 108 | + run: | |
| 109 | + git config user.name "github-actions[bot]" |
| 110 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 111 | + git add Formula/jam-cli.rb |
| 112 | + git diff --cached --quiet && echo "No changes" && exit 0 |
| 113 | + git commit -m "chore: bump jam-cli to ${{ steps.version.outputs.version }}" |
| 114 | + git push |
0 commit comments