Skip to content

brew bump

brew bump #471

Workflow file for this run

name: brew bump
on:
workflow_dispatch:
schedule:
# every day at 6am
- cron: 0 6 * * *
jobs:
get-formulae-and-casks:
name: Get formulae and casks
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.setmatrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
# https://stackoverflow.com/a/32354503/18839600
# first, get all formulae through `ls` and convert them into a JSON array
# then, map the json array to {name: <formula-name>[:-3], type: formula}
# [:-3] is to remove the .rb extension
- name: Get formulae
run: |
# shellcheck disable=SC2012
ls | jq -R -s 'split("\n")[:-1]' | jq 'map({name: .[:-3], type: "formula"})' > ../formulae.json
working-directory: Formula
# same as above, but for casks
- name: Get casks
run: |
# shellcheck disable=SC2012
ls | jq -R -s 'split("\n")[:-1]' | jq 'map({name: .[:-3], type: "cask"})' > ../casks.json
working-directory: Casks
# merge the two json arrays into one
- name: Output matrix
run: |
echo matrix="$(jq -s -c '.[0] + .[1]' formulae.json casks.json)" >> "$GITHUB_OUTPUT"
id: setmatrix
bump-versions:
needs: get-formulae-and-casks
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.get-formulae-and-casks.outputs.matrix) }}
name: Bump ${{ matrix.name }}
runs-on: macos-latest
steps:
- run: brew tap pavelzw/pavelzw
- name: brew livecheck ${{ matrix.name }}
run: |
set -euxo pipefail
brew developer on
brew livecheck "pavelzw/pavelzw/${{ matrix.name }}" --json | jq '.[0].version.outdated' > outdated
echo outdated="$(cat outdated)" >> "$GITHUB_OUTPUT"
brew livecheck "pavelzw/pavelzw/${{ matrix.name }}" --json | jq '.[0].version.latest' > new-version
echo new-version="$(cat new-version)" >> "$GITHUB_OUTPUT"
id: livecheck
shell: bash -euxo pipefail {0}
- name: Set up git
if: steps.livecheck.outputs.outdated == 'true'
run: |
git config --global user.email "[email protected]"
git config --global user.name pavelzw-bot
- name: brew bump-${{ matrix.type }}-pr ${{ matrix.name }}
if: steps.livecheck.outputs.outdated == 'true'
run: >-
brew bump-${{ matrix.type }}-pr
pavelzw/pavelzw/${{ matrix.name }}
--version=${{ steps.livecheck.outputs.new-version }}
--no-browse
env:
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}