@@ -149,65 +149,49 @@ jobs:
149149 name : Update Homebrew tap
150150 needs : release
151151 runs-on : ubuntu-latest
152- # Only run if the homebrew-tap repo exists (set secret HOMEBREW_TAP_TOKEN)
153- if : ${{ vars.HOMEBREW_TAP_ENABLED == 'true' }}
152+
154153 steps :
155154 - uses : actions/checkout@v4
156155
157- - name : Compute source tarball SHA256
156+ - name : Compute SHA256 for each binary
158157 id : sha
158+ shell : bash
159159 run : |
160- TAG=${{ github.ref_name }}
161- URL="https://github.com/rustkit-ai/tersify/archive/refs/tags/${TAG}.tar.gz"
162- SHA=$(curl -fsSL "$URL" | sha256sum | cut -d' ' -f1)
163- echo "sha256=$SHA" >> "$GITHUB_OUTPUT"
164- echo "url=$URL" >> "$GITHUB_OUTPUT"
165- echo "version=${TAG#v}" >> "$GITHUB_OUTPUT"
166-
167- - name : Update formula in homebrew-tap
168- uses : actions/github-script@v7
160+ VERSION="${GITHUB_REF_NAME#v}"
161+ BASE="https://github.com/rustkit-ai/tersify/releases/download/${GITHUB_REF_NAME}"
162+
163+ fetch_sha() {
164+ curl -fsSL "$1.sha256" | awk '{print $1}'
165+ }
166+
167+ echo "version=$VERSION" >> $GITHUB_OUTPUT
168+ echo "aarch64_darwin=$(fetch_sha $BASE/tersify-aarch64-apple-darwin.tar.gz)" >> $GITHUB_OUTPUT
169+ echo "x86_64_darwin=$(fetch_sha $BASE/tersify-x86_64-apple-darwin.tar.gz)" >> $GITHUB_OUTPUT
170+ echo "aarch64_linux=$(fetch_sha $BASE/tersify-aarch64-unknown-linux-musl.tar.gz)" >> $GITHUB_OUTPUT
171+ echo "x86_64_linux=$(fetch_sha $BASE/tersify-x86_64-unknown-linux-musl.tar.gz)" >> $GITHUB_OUTPUT
172+
173+ - name : Checkout tap repo
174+ uses : actions/checkout@v4
169175 with :
170- github-token : ${{ secrets.HOMEBREW_TAP_TOKEN }}
171- script : |
172- const { sha256, url, version } = ${{ toJson(steps.sha.outputs) }};
173- const formula = `class Tersify < Formula
174- desc "Universal LLM context compressor — pipe anything, get token-optimized output"
175- homepage "https://github.com/rustkit-ai/tersify"
176- url "${url}"
177- sha256 "${sha256}"
178- license "MIT"
179-
180- depends_on "rust" => :build
181-
182- def install
183- system "cargo", "install", *std_cargo_args
184- end
185-
186- def post_install
187- system "\#{bin}/tersify", "install", "--all"
188- rescue StandardError
189- nil
190- end
191-
192- test do
193- assert_match version.to_s, shell_output("\#{bin}/tersify --version")
194- (testpath/"test.rs").write("// comment\\nfn main() {}\\n")
195- output = shell_output("\#{bin}/tersify \#{testpath}/test.rs")
196- refute_match "// comment", output
197- end
198- end
199- `;
200- const owner = 'rustkit-ai';
201- const repo = 'homebrew-tap';
202- const path = 'Formula/tersify.rb';
203- let sha_file;
204- try {
205- const { data } = await github.rest.repos.getContent({ owner, repo, path });
206- sha_file = data.sha;
207- } catch {}
208- await github.rest.repos.createOrUpdateFileContents({
209- owner, repo, path,
210- message: `tersify ${version}`,
211- content: Buffer.from(formula).toString('base64'),
212- sha: sha_file,
213- });
176+ repository : rustkit-ai/homebrew-tap
177+ token : ${{ secrets.TAP_GITHUB_TOKEN }}
178+ path : tap
179+
180+ - name : Update formula
181+ shell : bash
182+ run : |
183+ F="tap/Formula/tersify.rb"
184+ sed -i "s/version \".*\"/version \"${{ steps.sha.outputs.version }}\"/" "$F"
185+ sed -i "s/PLACEHOLDER_AARCH64_DARWIN/${{ steps.sha.outputs.aarch64_darwin }}/" "$F"
186+ sed -i "s/PLACEHOLDER_X86_64_DARWIN/${{ steps.sha.outputs.x86_64_darwin }}/" "$F"
187+ sed -i "s/PLACEHOLDER_AARCH64_LINUX/${{ steps.sha.outputs.aarch64_linux }}/" "$F"
188+ sed -i "s/PLACEHOLDER_X86_64_LINUX/${{ steps.sha.outputs.x86_64_linux }}/" "$F"
189+
190+ - name : Commit + push to tap
191+ working-directory : tap
192+ run : |
193+ git config user.name "github-actions[bot]"
194+ git config user.email "github-actions[bot]@users.noreply.github.com"
195+ git add Formula/tersify.rb
196+ git commit -m "tersify ${{ steps.sha.outputs.version }}"
197+ git push
0 commit comments