-
Notifications
You must be signed in to change notification settings - Fork 4
119 lines (97 loc) · 3.89 KB
/
release.yml
File metadata and controls
119 lines (97 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
pull-requests: write
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.25"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_PAT: ${{ secrets.GH_PAT }}
- name: Get version and SHA256
id: release
run: |
VERSION=${GITHUB_REF#refs/tags/}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "npm_version=${VERSION#v}" >> $GITHUB_OUTPUT
TARBALL_URL="https://github.com/${{ github.repository }}/archive/refs/tags/$VERSION.tar.gz"
SHA256=$(curl -sL "$TARBALL_URL" | sha256sum | cut -d' ' -f1)
echo "sha256=$SHA256" >> $GITHUB_OUTPUT
- name: Update Homebrew Formula
run: |
VERSION=${{ steps.release.outputs.version }}
SHA256=${{ steps.release.outputs.sha256 }}
mkdir -p Formula
cat > Formula/agentx.rb << EOF
# typed: false
# frozen_string_literal: true
class Agentx < Formula
desc "CLI tool for managing MCP servers and skills across AI coding agents"
homepage "https://github.com/${{ github.repository }}"
url "https://github.com/${{ github.repository }}/archive/refs/tags/$VERSION.tar.gz"
sha256 "$SHA256"
license "Apache-2.0"
head "https://github.com/${{ github.repository }}.git", branch: "master"
depends_on "go" => :build
def install
ldflags = %W[
-s -w
-X github.com/agentsdance/agentx/internal/version.Version=#{version}
]
system "go", "build", *std_go_args(ldflags: ldflags)
end
test do
assert_match version.to_s, shell_output("#{bin}/agentx version")
end
end
EOF
- name: Update npm package version
run: |
NPM_VERSION=${{ steps.release.outputs.npm_version }}
node -e "const fs=require('fs');const p='package.json';const j=JSON.parse(fs.readFileSync(p,'utf8'));j.version='${NPM_VERSION}';fs.writeFileSync(p,JSON.stringify(j,null,2)+'\\n');"
- name: Commit and push Formula
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
DEFAULT_BRANCH="${{ github.event.repository.default_branch }}"
BRANCH_NAME="homebrew-${{ steps.release.outputs.version }}-${{ github.run_id }}"
git checkout -b "$BRANCH_NAME"
git add Formula/agentx.rb package.json
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "chore: update homebrew formula to ${{ steps.release.outputs.version }}"
git push origin "$BRANCH_NAME"
PR_URL=$(gh pr create \
--title "chore: update homebrew formula to ${{ steps.release.outputs.version }}" \
--body "Automated PR to update Homebrew formula for release ${{ steps.release.outputs.version }}" \
--base "$DEFAULT_BRANCH" \
--head "$BRANCH_NAME")
if gh pr merge --auto --squash "$PR_URL"; then
echo "✅ Auto-merge enabled for $PR_URL"
else
echo "⚠️ Auto-merge could not be enabled. Please merge PR manually: $PR_URL"
echo " Enable auto-merge in repo settings to make this fully automatic."
fi
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}