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