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