@@ -235,15 +235,56 @@ jobs:
235235 name : artifacts-dist-manifest
236236 path : dist-manifest.json
237237
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+
238278 # Create a GitHub Release while uploading all files to it
239279 announce :
240280 needs :
241281 - plan
242282 - host
283+ - publish-homebrew-formula
243284 # use "always() && ..." to allow us to wait for all publish jobs while
244285 # still allowing individual publish jobs to skip themselves (for prereleases).
245286 # "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') }}
247288 runs-on : " ubuntu-20.04"
248289 env :
249290 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments