Skip to content

Commit 338892e

Browse files
committed
Fix release workflow: use GITHUB_TOKEN, add homebrew auto-update
- Replace PUBLIC_REPO_TOKEN with github.token (releases are now on this repo) - Add update-homebrew job that auto-updates homebrew-cas formula after release - Requires HOMEBREW_TAP_TOKEN secret with push access to homebrew-cas repo
1 parent 1b7889b commit 338892e

1 file changed

Lines changed: 36 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,51 @@ jobs:
106106
echo "$NOTES" >> $GITHUB_OUTPUT
107107
echo "EOF" >> $GITHUB_OUTPUT
108108
109-
- name: Create Release on Public Repo
109+
- name: Create Release
110110
env:
111-
GH_TOKEN: ${{ secrets.PUBLIC_REPO_TOKEN }}
111+
GH_TOKEN: ${{ github.token }}
112112
run: |
113113
VERSION="${GITHUB_REF#refs/tags/}"
114114
115115
# Delete existing release if it exists (handles retags)
116116
gh release delete "$VERSION" --repo ${{ github.repository }} --yes 2>/dev/null || true
117117
118-
# Create the release on the public repo
118+
# Create the release
119119
gh release create "$VERSION" \
120120
--repo ${{ github.repository }} \
121121
--title "CAS $VERSION" \
122122
--notes "${{ steps.notes.outputs.notes }}" \
123123
release/*
124+
125+
update-homebrew:
126+
name: Update Homebrew Formula
127+
needs: release
128+
runs-on: ubuntu-latest
129+
steps:
130+
- uses: actions/checkout@v4
131+
132+
- name: Update Homebrew formula
133+
env:
134+
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
135+
run: |
136+
VERSION="${GITHUB_REF#refs/tags/v}"
137+
138+
# Download and compute SHA256 for each platform
139+
MACOS_SHA=$(curl -fsSL "https://github.com/${{ github.repository }}/releases/download/v${VERSION}/cas-aarch64-apple-darwin.tar.gz" | shasum -a 256 | cut -d' ' -f1)
140+
LINUX_SHA=$(curl -fsSL "https://github.com/${{ github.repository }}/releases/download/v${VERSION}/cas-x86_64-unknown-linux-gnu.tar.gz" | shasum -a 256 | cut -d' ' -f1)
141+
142+
# Clone homebrew-cas tap
143+
git clone https://x-access-token:${GH_TOKEN}@github.com/codingagentsystem/homebrew-cas.git /tmp/homebrew-cas
144+
cd /tmp/homebrew-cas
145+
146+
# Update version and SHA256 hashes in formula
147+
sed -i "s/version \"[^\"]*\"/version \"${VERSION}\"/" Formula/cas.rb
148+
sed -i "0,/sha256 \"[a-f0-9]\{64\}\"/s/sha256 \"[a-f0-9]\{64\}\"/sha256 \"${MACOS_SHA}\"/" Formula/cas.rb
149+
sed -i "/sha256 \"${MACOS_SHA}\"/!s/sha256 \"[a-f0-9]\{64\}\"/sha256 \"${LINUX_SHA}\"/" Formula/cas.rb
150+
151+
# Commit and push
152+
git config user.name "github-actions[bot]"
153+
git config user.email "github-actions[bot]@users.noreply.github.com"
154+
git add Formula/cas.rb
155+
git commit -m "Update CAS to ${VERSION}"
156+
git push

0 commit comments

Comments
 (0)