@@ -273,14 +273,60 @@ jobs:
273
273
274
274
gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
275
275
276
+ publish-homebrew-formula :
277
+ needs :
278
+ - plan
279
+ - host
280
+ runs-on : " ubuntu-20.04"
281
+ env :
282
+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
283
+ PLAN : ${{ needs.plan.outputs.val }}
284
+ GITHUB_USER : " axo bot"
285
+ GITHUB_EMAIL : " admin+bot@axo.dev"
286
+ if : ${{ !fromJson(needs.plan.outputs.val).announcement_is_prerelease || fromJson(needs.plan.outputs.val).publish_prereleases }}
287
+ steps :
288
+ - uses : actions/checkout@v4
289
+ with :
290
+ repository : " jacktabscode/homebrew-tap"
291
+ token : ${{ secrets.HOMEBREW_TAP_TOKEN }}
292
+ # So we have access to the formula
293
+ - name : Fetch homebrew formulae
294
+ uses : actions/download-artifact@v4
295
+ with :
296
+ pattern : artifacts-*
297
+ path : Formula/
298
+ merge-multiple : true
299
+ # This is extra complex because you can make your Formula name not match your app name
300
+ # so we need to find releases with a *.rb file, and publish with that filename.
301
+ - name : Commit formula files
302
+ run : |
303
+ git config --global user.name "${GITHUB_USER}"
304
+ git config --global user.email "${GITHUB_EMAIL}"
305
+
306
+ for release in $(echo "$PLAN" | jq --compact-output '.releases[] | select([.artifacts[] | endswith(".rb")] | any)'); do
307
+ filename=$(echo "$release" | jq '.artifacts[] | select(endswith(".rb"))' --raw-output)
308
+ name=$(echo "$filename" | sed "s/\.rb$//")
309
+ version=$(echo "$release" | jq .app_version --raw-output)
310
+
311
+ export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
312
+ brew update
313
+ # We avoid reformatting user-provided data such as the app description and homepage.
314
+ brew style --except-cops FormulaAudit/Homepage,FormulaAudit/Desc,FormulaAuditStrict --fix "Formula/${filename}" || true
315
+
316
+ git add "Formula/${filename}"
317
+ git commit -m "${name} ${version}"
318
+ done
319
+ git push
320
+
276
321
announce :
277
322
needs :
278
323
- plan
279
324
- host
325
+ - publish-homebrew-formula
280
326
# use "always() && ..." to allow us to wait for all publish jobs while
281
327
# still allowing individual publish jobs to skip themselves (for prereleases).
282
328
# "host" however must run to completion, no skipping allowed!
283
- if : ${{ always() && needs.host.result == 'success' }}
329
+ if : ${{ always() && needs.host.result == 'success' && (needs.publish-homebrew-formula.result == 'skipped' || needs.publish-homebrew-formula.result == 'success') }}
284
330
runs-on : " ubuntu-20.04"
285
331
env :
286
332
GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments