-
Notifications
You must be signed in to change notification settings - Fork 9
47 lines (45 loc) · 2.3 KB
/
update-homebrew.yml
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
name: Update Homebrew Formula
on:
release:
types: [released]
jobs:
update-homebrew-formula:
name: Update Homebrew Formula
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get Latest Release
id: release
env:
GH_TOKEN: ${{ github.token }}
run: |
# Download files from the latest release and calculate their SHA256 checksums
gh release view --json tagName,assets > release.json
gh release download -p '*apple-darwin*'
echo "VERSION=$(jq -r '.tagName' release.json)" >> $GITHUB_OUTPUT
echo "X86_URL=$(jq -r '.assets[] | select(.name | contains("x86_64-apple-darwin")) | .url' release.json)" >> $GITHUB_OUTPUT
echo "ARM_URL=$(jq -r '.assets[] | select(.name | contains("aarch64-apple-darwin")) | .url' release.json)" >> $GITHUB_OUTPUT
echo "X86_SHA=$(sha256sum ceramic-one_x86_64-apple-darwin.bin.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
echo "ARM_SHA=$(sha256sum ceramic-one_aarch64-apple-darwin.bin.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
- name: Checkout Homebrew Tap
uses: actions/checkout@v4
with:
repository: ceramicnetwork/homebrew-tap
path: homebrew-tap
token: ${{ secrets.GH_TOKEN_PAT }}
- name: Update Homebrew Formula
run: |
cd homebrew-tap
sed -i -E "s|(url \".*ceramic-one_x86_64-apple-darwin.*\")|url \"${{ steps.release.outputs.X86_URL }}\"|" Formula/ceramic-one.rb
sed -i -E "/CPU.intel?/,/sha256/ s/sha256 \"[^\"]*\"/sha256 \"${{ steps.release.outputs.X86_SHA }}\"/" Formula/ceramic-one.rb
sed -i -E "s|(url \".*ceramic-one_aarch64-apple-darwin.*\")|url \"${{ steps.release.outputs.ARM_URL }}\"|" Formula/ceramic-one.rb
sed -i -E "/CPU.arm?/,/sha256/ s/sha256 \"[^\"]*\"/sha256 \"${{ steps.release.outputs.ARM_SHA }}\"/" Formula/ceramic-one.rb
- name: Commit and Push changes
run: |
cd homebrew-tap
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git diff
git add Formula/ceramic-one.rb
git commit -m "chore: update ceramic-one formula to ${{ steps.release.outputs.VERSION }}"
git push