|
31 | 31 | env: |
32 | 32 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
33 | 33 | GH_PAT: ${{ secrets.GH_PAT }} |
| 34 | + |
| 35 | + - name: Get version and SHA256 |
| 36 | + id: release |
| 37 | + run: | |
| 38 | + VERSION=${GITHUB_REF#refs/tags/} |
| 39 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 40 | +
|
| 41 | + TARBALL_URL="https://github.com/${{ github.repository }}/archive/refs/tags/$VERSION.tar.gz" |
| 42 | + SHA256=$(curl -sL "$TARBALL_URL" | sha256sum | cut -d' ' -f1) |
| 43 | + echo "sha256=$SHA256" >> $GITHUB_OUTPUT |
| 44 | +
|
| 45 | + - name: Update Homebrew Formula |
| 46 | + run: | |
| 47 | + VERSION=${{ steps.release.outputs.version }} |
| 48 | + SHA256=${{ steps.release.outputs.sha256 }} |
| 49 | +
|
| 50 | + mkdir -p Formula |
| 51 | +
|
| 52 | + cat > Formula/agentx.rb << EOF |
| 53 | + # typed: false |
| 54 | + # frozen_string_literal: true |
| 55 | +
|
| 56 | + class Agentx < Formula |
| 57 | + desc "CLI tool for managing MCP servers and skills across AI coding agents" |
| 58 | + homepage "https://github.com/${{ github.repository }}" |
| 59 | + url "https://github.com/${{ github.repository }}/archive/refs/tags/$VERSION.tar.gz" |
| 60 | + sha256 "$SHA256" |
| 61 | + license "Apache-2.0" |
| 62 | + head "https://github.com/${{ github.repository }}.git", branch: "master" |
| 63 | +
|
| 64 | + depends_on "go" => :build |
| 65 | +
|
| 66 | + def install |
| 67 | + ldflags = %W[ |
| 68 | + -s -w |
| 69 | + -X github.com/agentsdance/agentx/internal/version.Version=#{version} |
| 70 | + ] |
| 71 | + system "go", "build", *std_go_args(ldflags: ldflags) |
| 72 | + end |
| 73 | +
|
| 74 | + test do |
| 75 | + assert_match version.to_s, shell_output("#{bin}/agentx version") |
| 76 | + end |
| 77 | + end |
| 78 | + EOF |
| 79 | +
|
| 80 | + - name: Commit and push Formula |
| 81 | + run: | |
| 82 | + git config --local user.email "action@github.com" |
| 83 | + git config --local user.name "GitHub Action" |
| 84 | +
|
| 85 | + git add Formula/agentx.rb |
| 86 | +
|
| 87 | + if git diff --staged --quiet; then |
| 88 | + echo "No changes to commit" |
| 89 | + else |
| 90 | + git commit -m "chore: update homebrew formula to ${{ steps.release.outputs.version }}" |
| 91 | + git push origin HEAD:master |
| 92 | + fi |
0 commit comments