Skip to content

Commit e2b03d6

Browse files
committed
Fix Homebrew formula update: use gh CLI instead of curl for checksum download
1 parent 4a3791b commit e2b03d6

1 file changed

Lines changed: 13 additions & 20 deletions

File tree

.github/workflows/release.yml

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ jobs:
128128
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
129129

130130
- name: Download checksums
131+
env:
132+
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
131133
run: |
132-
VERSION=${{ steps.version.outputs.version }}
133134
TAG=${GITHUB_REF_NAME}
134-
BASE_URL="https://github.com/hulryung/xcli/releases/download/${TAG}"
135135
for target in x86_64-apple-darwin aarch64-apple-darwin x86_64-unknown-linux-musl aarch64-unknown-linux-musl; do
136-
curl -sL "${BASE_URL}/xcli-${target}.tar.gz.sha256" -o "xcli-${target}.tar.gz.sha256"
136+
gh release download "${TAG}" --repo hulryung/xcli --pattern "xcli-${target}.tar.gz.sha256"
137137
done
138138
139139
- name: Extract checksums
@@ -155,30 +155,30 @@ jobs:
155155
run: |
156156
VERSION=${{ steps.version.outputs.version }}
157157
TAG=${GITHUB_REF_NAME}
158-
cat > homebrew-xcli/Formula/xcli.rb << 'FORMULA'
158+
cat > homebrew-xcli/Formula/xcli.rb <<FORMULA
159159
class Xcli < Formula
160160
desc "X (Twitter) API CLI tool"
161161
homepage "https://github.com/hulryung/xcli"
162-
version "VERSION_PLACEHOLDER"
162+
version "${VERSION}"
163163
license "MIT"
164164
165165
on_macos do
166166
if Hardware::CPU.intel?
167-
url "https://github.com/hulryung/xcli/releases/download/TAG_PLACEHOLDER/xcli-x86_64-apple-darwin.tar.gz"
168-
sha256 "SHA_X86_64_APPLE"
167+
url "https://github.com/hulryung/xcli/releases/download/${TAG}/xcli-x86_64-apple-darwin.tar.gz"
168+
sha256 "${{ steps.sha.outputs.x86_64_apple }}"
169169
else
170-
url "https://github.com/hulryung/xcli/releases/download/TAG_PLACEHOLDER/xcli-aarch64-apple-darwin.tar.gz"
171-
sha256 "SHA_AARCH64_APPLE"
170+
url "https://github.com/hulryung/xcli/releases/download/${TAG}/xcli-aarch64-apple-darwin.tar.gz"
171+
sha256 "${{ steps.sha.outputs.aarch64_apple }}"
172172
end
173173
end
174174
175175
on_linux do
176176
if Hardware::CPU.intel?
177-
url "https://github.com/hulryung/xcli/releases/download/TAG_PLACEHOLDER/xcli-x86_64-unknown-linux-musl.tar.gz"
178-
sha256 "SHA_X86_64_LINUX"
177+
url "https://github.com/hulryung/xcli/releases/download/${TAG}/xcli-x86_64-unknown-linux-musl.tar.gz"
178+
sha256 "${{ steps.sha.outputs.x86_64_linux }}"
179179
else
180-
url "https://github.com/hulryung/xcli/releases/download/TAG_PLACEHOLDER/xcli-aarch64-unknown-linux-musl.tar.gz"
181-
sha256 "SHA_AARCH64_LINUX"
180+
url "https://github.com/hulryung/xcli/releases/download/${TAG}/xcli-aarch64-unknown-linux-musl.tar.gz"
181+
sha256 "${{ steps.sha.outputs.aarch64_linux }}"
182182
end
183183
end
184184
@@ -192,13 +192,6 @@ jobs:
192192
end
193193
FORMULA
194194
195-
sed -i "s/VERSION_PLACEHOLDER/${VERSION}/g" homebrew-xcli/Formula/xcli.rb
196-
sed -i "s/TAG_PLACEHOLDER/${TAG}/g" homebrew-xcli/Formula/xcli.rb
197-
sed -i "s/SHA_X86_64_APPLE/${{ steps.sha.outputs.x86_64_apple }}/g" homebrew-xcli/Formula/xcli.rb
198-
sed -i "s/SHA_AARCH64_APPLE/${{ steps.sha.outputs.aarch64_apple }}/g" homebrew-xcli/Formula/xcli.rb
199-
sed -i "s/SHA_X86_64_LINUX/${{ steps.sha.outputs.x86_64_linux }}/g" homebrew-xcli/Formula/xcli.rb
200-
sed -i "s/SHA_AARCH64_LINUX/${{ steps.sha.outputs.aarch64_linux }}/g" homebrew-xcli/Formula/xcli.rb
201-
202195
- name: Commit and push formula
203196
run: |
204197
cd homebrew-xcli

0 commit comments

Comments
 (0)