@@ -235,15 +235,56 @@ jobs:
235
235
name : artifacts-dist-manifest
236
236
path : dist-manifest.json
237
237
238
+ publish-homebrew-formula :
239
+ needs :
240
+ - plan
241
+ - host
242
+ runs-on : " ubuntu-20.04"
243
+ env :
244
+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
245
+ PLAN : ${{ needs.plan.outputs.val }}
246
+ GITHUB_USER : " axo bot"
247
+
248
+ if : ${{ !fromJson(needs.plan.outputs.val).announcement_is_prerelease || fromJson(needs.plan.outputs.val).publish_prereleases }}
249
+ steps :
250
+ - uses : actions/checkout@v4
251
+ with :
252
+ repository : " marcfrederick/homebrew-tap"
253
+ token : ${{ secrets.HOMEBREW_TAP_TOKEN }}
254
+ # So we have access to the formula
255
+ - name : Fetch homebrew formulae
256
+ uses : actions/download-artifact@v4
257
+ with :
258
+ pattern : artifacts-*
259
+ path : Formula/
260
+ merge-multiple : true
261
+ # This is extra complex because you can make your Formula name not match your app name
262
+ # so we need to find releases with a *.rb file, and publish with that filename.
263
+ - name : Commit formula files
264
+ run : |
265
+ git config --global user.name "${GITHUB_USER}"
266
+ git config --global user.email "${GITHUB_EMAIL}"
267
+
268
+ for release in $(echo "$PLAN" | jq --compact-output '.releases[] | select([.artifacts[] | endswith(".rb")] | any)'); do
269
+ filename=$(echo "$release" | jq '.artifacts[] | select(endswith(".rb"))' --raw-output)
270
+ name=$(echo "$filename" | sed "s/\.rb$//")
271
+ version=$(echo "$release" | jq .app_version --raw-output)
272
+
273
+ git add "Formula/${filename}"
274
+ git commit -m "${name} ${version}"
275
+ done
276
+ git push
277
+
238
278
# Create a GitHub Release while uploading all files to it
239
279
announce :
240
280
needs :
241
281
- plan
242
282
- host
283
+ - publish-homebrew-formula
243
284
# use "always() && ..." to allow us to wait for all publish jobs while
244
285
# still allowing individual publish jobs to skip themselves (for prereleases).
245
286
# "host" however must run to completion, no skipping allowed!
246
- if : ${{ always() && needs.host.result == 'success' }}
287
+ if : ${{ always() && needs.host.result == 'success' && (needs.publish-homebrew-formula.result == 'skipped' || needs.publish-homebrew-formula.result == 'success') }}
247
288
runs-on : " ubuntu-20.04"
248
289
env :
249
290
GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments