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