Skip to content

Commit 949497d

Browse files
committed
ci: auto-update Homebrew Cask after release publish
1 parent 8718a7f commit 949497d

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,71 @@ jobs:
104104
env:
105105
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
106106
run: gh release edit "${{ needs.create-release.outputs.tag_name }}" --repo "${{ github.repository }}" --draft=false
107+
108+
update-homebrew:
109+
needs: [create-release, publish-release]
110+
runs-on: ubuntu-latest
111+
steps:
112+
- name: Download macOS DMGs and compute SHA256
113+
id: sha
114+
env:
115+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
116+
VERSION: ${{ needs.create-release.outputs.version }}
117+
run: |
118+
BASE="https://github.com/${{ github.repository }}/releases/download/v${VERSION}"
119+
curl -sL "${BASE}/Arandu_${VERSION}_aarch64.dmg" -o arm.dmg
120+
curl -sL "${BASE}/Arandu_${VERSION}_x64.dmg" -o intel.dmg
121+
echo "arm=$(sha256sum arm.dmg | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
122+
echo "intel=$(sha256sum intel.dmg | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
123+
124+
- name: Update Cask in homebrew tap
125+
env:
126+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127+
VERSION: ${{ needs.create-release.outputs.version }}
128+
SHA_ARM: ${{ steps.sha.outputs.arm }}
129+
SHA_INTEL: ${{ steps.sha.outputs.intel }}
130+
run: |
131+
CASK=$(cat <<RUBY
132+
cask "arandu" do
133+
version "${VERSION}"
134+
135+
on_arm do
136+
sha256 "${SHA_ARM}"
137+
url "https://github.com/devitools/arandu/releases/download/v#{version}/Arandu_#{version}_aarch64.dmg"
138+
end
139+
on_intel do
140+
sha256 "${SHA_INTEL}"
141+
url "https://github.com/devitools/arandu/releases/download/v#{version}/Arandu_#{version}_x64.dmg"
142+
end
143+
144+
name "Arandu"
145+
desc "Minimal Markdown viewer with GFM support, syntax highlighting, and live reload"
146+
homepage "https://github.com/devitools/arandu"
147+
148+
depends_on macos: ">= :ventura"
149+
150+
app "Arandu.app"
151+
152+
postflight do
153+
system_command "/usr/bin/xattr",
154+
args: ["-cr", "#{appdir}/Arandu.app"],
155+
sudo: false
156+
end
157+
158+
zap trash: [
159+
"~/Library/Application Support/com.devitools.arandu",
160+
"~/Library/Caches/com.devitools.arandu",
161+
"~/Library/Preferences/com.devitools.arandu.plist",
162+
]
163+
end
164+
RUBY
165+
)
166+
167+
FILE_SHA=$(gh api repos/devitools/homebrew-arandu/contents/Casks/arandu.rb --jq '.sha')
168+
CONTENT=$(echo "$CASK" | base64 -w 0)
169+
170+
gh api repos/devitools/homebrew-arandu/contents/Casks/arandu.rb \
171+
-X PUT \
172+
-f message="chore: update Cask to v${VERSION}" \
173+
-f content="$CONTENT" \
174+
-f sha="$FILE_SHA"

0 commit comments

Comments
 (0)