|
88 | 88 | uses: dtolnay/rust-toolchain@stable |
89 | 89 |
|
90 | 90 | - name: Publish |
91 | | - run: cargo publish --token ${{ secrets.CRATES_IO_TOKEN }} |
| 91 | + run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} |
92 | 92 |
|
93 | 93 | # ── Update Homebrew tap automatically ───────────────────────────────────── |
94 | 94 | homebrew: |
@@ -174,20 +174,22 @@ jobs: |
174 | 174 | set -e |
175 | 175 | CONTENT=$(base64 -w 0 /tmp/krait.rb) |
176 | 176 |
|
177 | | - RESPONSE=$(curl -sf \ |
| 177 | + # Get existing file SHA if it exists (empty on first release) |
| 178 | + FILE_SHA=$(curl -s \ |
178 | 179 | -H "Authorization: token $TAP_TOKEN" \ |
179 | | - "https://api.github.com/repos/Codestz/homebrew-krait/contents/Formula/krait.rb") |
180 | | - FILE_SHA=$(echo "$RESPONSE" | jq -r '.sha') |
| 180 | + "https://api.github.com/repos/Codestz/homebrew-krait/contents/Formula/krait.rb" \ |
| 181 | + | jq -r '.sha // empty') |
181 | 182 |
|
182 | | - if [ "$FILE_SHA" = "null" ] || [ -z "$FILE_SHA" ]; then |
183 | | - echo "::error::Failed to get file SHA from tap repo. Check HOMEBREW_TAP_TOKEN." |
184 | | - exit 1 |
| 183 | + if [ -n "$FILE_SHA" ]; then |
| 184 | + PAYLOAD="{\"message\":\"chore: bump to v${VERSION}\",\"content\":\"${CONTENT}\",\"sha\":\"${FILE_SHA}\"}" |
| 185 | + else |
| 186 | + PAYLOAD="{\"message\":\"chore: add formula for v${VERSION}\",\"content\":\"${CONTENT}\"}" |
185 | 187 | fi |
186 | 188 |
|
187 | 189 | curl -sf -X PUT \ |
188 | 190 | -H "Authorization: token $TAP_TOKEN" \ |
189 | 191 | -H "Content-Type: application/json" \ |
190 | 192 | "https://api.github.com/repos/Codestz/homebrew-krait/contents/Formula/krait.rb" \ |
191 | | - -d "{\"message\":\"chore: bump to v${VERSION}\",\"content\":\"${CONTENT}\",\"sha\":\"${FILE_SHA}\"}" |
| 193 | + -d "$PAYLOAD" |
192 | 194 |
|
193 | 195 | echo "Homebrew tap updated to v${VERSION}" |
0 commit comments