Update a formula #10
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update a formula | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
subject: | ||
description: which formula to update? | ||
required: true | ||
type: choice | ||
options: | ||
- cli | ||
- gomod | ||
version: | ||
description: which version shall be published | ||
required: true | ||
type: string | ||
defaults: | ||
env: | ||
UF_SUBJECT: ${{ github.event.inputs.subject }} | ||
UF_VERSION: ${{ github.event.inputs.version }} | ||
ARTIFACT_FORMULA: formula | ||
ARTIFACT_FORMULA_FIXED: formula_fixed | ||
jobs: | ||
update: | ||
name: "update formula: ${{ github.event.inputs.subject }} ${{ github.event.inputs.version }}" | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- name: Checkout | ||
# see https://github.com/actions/checkout | ||
uses: actions/checkout@v4 | ||
- name: Update Formula | ||
run: > | ||
.github/scripts/update-formula/"$UF_SUBJECT"/gen.sh | ||
"${UF_VERSION}" | ||
> Formula/cyclonedx-"$UF_SUBJECT".rb | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Artifact Formula | ||
# https://github.com/actions/upload-artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ env.ARTIFACT_FORMULA }} | ||
path: Formula/cyclonedx-${{ env.UF_SUBJECT }}.rb | ||
if-no-files-found: error | ||
retention-days: 3 | ||
fix-test: | ||
# https://docs.brew.sh/Adding-Software-to-Homebrew#testing-and-auditing-the-formula | ||
needs: [ "update" ] | ||
name: "Fix & Test formula" | ||
runs-on: macos-latest | ||
timeout-minutes: 10 | ||
env: | ||
HOMEBREW_NO_AUTO_UPDATE: '1' | ||
HOMEBREW_NO_INSTALL_FROM_API: '1' | ||
TAP_TESTING: 'local/testing' | ||
steps: | ||
- run: brew developer on | ||
- name: Fetch Formula | ||
# https://github.com/actions/download-artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ env.ARTIFACT_FORMULA }} | ||
- name: tap | ||
run: | | ||
brew tap-new "$TAP_TESTING" --no-git | ||
ln -s "$PWD/cyclonedx-${UF_SUBJECT}.rb" "$(brew --repo "$TAP_TESTING")"/Formula/ | ||
- name: Audit & fix Formula | ||
run: brew audit --fix --stric --online "${TAP_TESTING}/cyclonedx-${UF_SUBJECT}" | ||
- name: Artifact fixed Formula | ||
# https://github.com/actions/upload-artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ env.ARTIFACT_FORMULA_FIXED }} | ||
path: cyclonedx-${{ env.UF_SUBJECT }}.rb | ||
if-no-files-found: error | ||
retention-days: 3 | ||
- name: Test Formula | ||
run: | | ||
FORMULA="${TAP_TESTING}/cyclonedx-${UF_SUBJECT}" | ||
brew install --build-from-source "$FORMULA" | ||
brew deps "$FORMULA" | ||
brew test --verbose "$FORMULA" | ||
brew uninstall "$FORMULA" | ||
pullrequest: | ||
permissions: | ||
contents: write # push commits | ||
pull-requests: write # create pullrequests | ||
needs: [ "fix-test" ] | ||
name: "Commit formula" | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- name: Checkout | ||
# see https://github.com/actions/checkout | ||
uses: actions/checkout@v4 | ||
- name: Fetch fixed Formula | ||
# https://github.com/actions/download-artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ env.ARTIFACT_FORMULA_FIXED }} | ||
path: Formula | ||
- name: Commit & Push | ||
run: | | ||
BRANCH_NAME="update-formula/${UF_SUBJECT}-${UF_VERSION}" | ||
git checkout -B "$BRANCH_NAME" | ||
git add -A Formula | ||
git config user.name "[BOT] Formula Updater" | ||
git config user.email "[email protected]" | ||
git commit -s -m "Update ${UF_SUBJECT}: ${UF_VERSION}" | ||
git push -f --set-upstream origin "$BRANCH_NAME" | ||
- name: Open PullRequest | ||
run: gh pr create --fill-verbose --label "${UF_SUBJECT} ${UF_VERSION}" | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |