Skip to content

Update formula

Update formula #41

name: Update formula
on:
workflow_dispatch:
inputs:
package:
description: 'Package / formula name'
required: true
type: string
version:
description: 'Package version'
required: true
type: string
workflow_call:
inputs:
package:
description: 'Package / formula name'
required: true
type: string
version:
description: 'Package version'
required: true
type: string
jobs:
test-updated-formula:
name: Test updated formula
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Update package in formula
run: ./.github/scripts/update_formula.sh ${{ github.event.inputs.package }} ${{ github.event.inputs.version }}
- name: Test updated formula
run: |
set -o errexit
export HOMEBREW_NO_AUTO_UPDATE=1
export HOMEBREW_NO_ANALYTICS=1
export HOMEBREW_NO_INSTALL_CLEANUP=1
# Disable formula migrations for this test,
# otherwise `brew install` would install the formula from homebrew-core instead of the local repository clone
rm ./tap_migrations.json
# Install the updated formula
# (due to setup-homebrew magic, the working directory is also considered as a tap, so no need to copy around the updated formula file)
brew install $GITHUB_REPOSITORY/${{ github.event.inputs.package }}
# Run the formula tests
brew test ${{ github.event.inputs.package }}
update-formula:
name: Update formula and commit result
needs: [test-updated-formula]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Update package version and commit result
env:
GH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
run: |
set -o errexit
./.github/scripts/update_formula.sh ${{ github.event.inputs.package }} ${{ github.event.inputs.version }}
git config user.name 'Apify Service Account'
git config user.email '64261774+apify-service-account@users.noreply.github.com'
git checkout -b feat/update-${{ github.event.inputs.package }}-to-${{ github.event.inputs.version }}
git add Formula/${{ github.event.inputs.package }}.rb
git commit -m "Updating \`${{ github.event.inputs.package }}\` to version \`${{ github.event.inputs.version }}\`"
git push --set-upstream origin feat/update-${{ github.event.inputs.package }}-to-${{ github.event.inputs.version }}
gh pr create --fill --base ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
gh pr merge --auto --squash --delete-branch