Skip to content

Build bottle of fwupd on 12,13,14 #52915

Build bottle of fwupd on 12,13,14

Build bottle of fwupd on 12,13,14 #52915

name: Dispatch build bottle (for chosen OS versions)
run-name: Build bottle of ${{ inputs.formula }} on ${{ inputs.runner }}
on:
workflow_dispatch:
inputs:
runner:
description: Build runner(s) (macOS version or Linux)
required: true
formula:
description: Formula name
required: true
timeout:
description: "Build timeout (in minutes, default: 60 minutes)"
default: "60"
required: false
issue:
description: Issue number, where comment on failure would be posted
required: false
upload:
description: "Upload built bottles? (default: false)"
type: boolean
default: false
required: false
env:
HOMEBREW_DEVELOPER: 1
HOMEBREW_GITHUB_ACTIONS: 1
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_FROM_API: 1
RUN_URL: ${{github.event.repository.html_url}}/actions/runs/${{github.run_id}}
# Intentionally the same as dispatch-rebottle
concurrency: bottle-${{ github.event.inputs.formula }}
permissions:
contents: read
jobs:
prepare:
runs-on: ubuntu-22.04
outputs:
runners: ${{steps.runner-matrix.outputs.result}}
steps:
- name: Prepare runner matrix
id: runner-matrix
uses: actions/github-script@v7
with:
script: |
const macOSRegex = /^\d+(?:\.\d+)?(?:-arm64)?$/;
const linuxRegex = /^(ubuntu-|linux-self-hosted-)/;
return context.payload.inputs.runner.split(",")
.map(s => s.trim())
.filter(Boolean)
.map(s => {
if (macOSRegex.test(s) && s != "11-arm64") // Ephemeral runners
return {runner: `${s}-${context.runId}`, cleanup: false};
else if (linuxRegex.test(s))
return {
runner: s,
container: {
image: "ghcr.io/homebrew/ubuntu22.04:master",
options: "--user=linuxbrew -e GITHUB_ACTIONS_HOMEBREW_SELF_HOSTED"
},
workdir: "/github/home",
cleanup: false
};
else
return {runner: s, cleanup: true};
});
bottle:
needs: prepare
strategy:
matrix:
include: ${{fromJson(needs.prepare.outputs.runners)}}
runs-on: ${{matrix.runner}}
container: ${{matrix.container}}
timeout-minutes: ${{fromJson(github.event.inputs.timeout)}}
permissions:
contents: read
defaults:
run:
shell: /bin/bash -e {0}
working-directory: ${{matrix.workdir || github.workspace}}
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
HOMEBREW_GITHUB_API_TOKEN: ${{secrets.GITHUB_TOKEN}}
BOTTLES_DIR: ${{ matrix.workdir || github.workspace }}/bottles
steps:
- name: ${{inputs.formula}}
id: print_details
run: |
echo sender='${{github.event.sender.login}}'
echo formula='${{inputs.formula}}'
echo runner='${{inputs.runner}}'
echo timeout='${{inputs.timeout}}'
echo issue='${{inputs.issue}}'
echo upload='${{inputs.upload}}'
- name: Pre-test steps
uses: Homebrew/actions/pre-build@master
with:
bottles-directory: ${{ env.BOTTLES_DIR }}
cleanup: ${{ matrix.cleanup }}
- working-directory: ${{ env.BOTTLES_DIR }}
run: |
brew test-bot \
--only-formulae \
--keep-old \
--only-json-tab \
--skip-online-checks \
--skip-dependents \
'${{inputs.formula}}'
- name: Post-build steps
if: always()
uses: Homebrew/actions/post-build@master
with:
runner: ${{ matrix.runner }}
cleanup: ${{ matrix.cleanup }}
bottles-directory: ${{ env.BOTTLES_DIR }}
logs-directory: ${{ env.BOTTLES_DIR }}/logs
upload:
permissions:
contents: read
issues: write # for Homebrew/actions/post-comment
pull-requests: write # for `gh pr edit`
runs-on: ubuntu-latest
needs: bottle
if: inputs.upload
container:
image: ghcr.io/homebrew/ubuntu22.04:master
defaults:
run:
shell: bash
env:
HOMEBREW_SIMULATE_MACOS_ON_LINUX: 1
GH_REPO: ${{github.repository}}
GH_NO_UPDATE_NOTIFIER: 1
GH_PROMPT_DISABLED: 1
BOTTLE_BRANCH: ${{github.actor}}/dispatch/${{inputs.formula}}/${{github.run_id}}
steps:
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
with:
core: true
cask: false
test-bot: false
- name: Download bottles from GitHub Actions
uses: actions/download-artifact@v4
with:
pattern: bottles_*
path: ~/bottles/
merge-multiple: true
- name: Configure Git user
id: git-user-config
uses: Homebrew/actions/git-user-config@master
with:
username: ${{ (github.actor != 'github-actions[bot]' && github.actor) || 'BrewTestBot' }}
- name: Set up commit signing
uses: Homebrew/actions/setup-commit-signing@master
with:
signing_key: ${{ secrets.BREWTESTBOT_GPG_SIGNING_SUBKEY }}
- name: Checkout branch for bottle commit
working-directory: ${{steps.set-up-homebrew.outputs.repository-path}}
run: git checkout -b "$BOTTLE_BRANCH" origin/master
- name: Upload bottles to GitHub Packages
env:
HOMEBREW_GITHUB_PACKAGES_USER: brewtestbot
HOMEBREW_GITHUB_PACKAGES_TOKEN: ${{secrets.HOMEBREW_CORE_GITHUB_PACKAGES_TOKEN}}
HOMEBREW_GPG_PASSPHRASE: ${{ secrets.BREWTESTBOT_GPG_SIGNING_SUBKEY_PASSPHRASE }}
BREWTESTBOT_NAME_EMAIL: "BrewTestBot <[email protected]>"
run: |
cd ~/bottles
brew pr-upload --verbose --keep-old --committer="$BREWTESTBOT_NAME_EMAIL" --root-url="https://ghcr.io/v2/homebrew/core"
- name: Push commits
uses: Homebrew/actions/git-try-push@master
with:
token: ${{secrets.HOMEBREW_GITHUB_PUBLIC_REPO_TOKEN}}
directory: ${{steps.set-up-homebrew.outputs.repository-path}}
branch: ${{env.BOTTLE_BRANCH}}
env:
GIT_COMMITTER_NAME: BrewTestBot
GIT_COMMITTER_EMAIL: [email protected]
HOMEBREW_GPG_PASSPHRASE: ${{ secrets.BREWTESTBOT_GPG_SIGNING_SUBKEY_PASSPHRASE }}
- name: Open PR with bottle commit
id: create-pr
working-directory: ${{steps.set-up-homebrew.outputs.repository-path}}
env:
GH_TOKEN: ${{secrets.HOMEBREW_GITHUB_PUBLIC_REPO_TOKEN}}
run: |
gh pr create \
--base "$GITHUB_REF" \
--body "Created by [\`brew dispatch-build-bottle\`]($RUN_URL)" \
--title "$(git log -1 --format='%s' "$BOTTLE_BRANCH")" \
--head "$BOTTLE_BRANCH" \
--reviewer '${{github.actor}}'
pull_number="$(gh pr list --head "$BOTTLE_BRANCH" --limit 1 --json number --jq '.[].number')"
echo "pull_number=$pull_number" >> "$GITHUB_OUTPUT"
echo "head_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
# There is a GitHub bug where labels are not properly recognised by workflows
# when added by `gh pr create`. We use the CI-published-bottle-commits label in
# the `formulae_detect` step in `tests.yml`, so let's add the label separately
# to avoid the bug.
- name: Label PR
env:
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
PR: ${{steps.create-pr.outputs.pull_number}}
run: gh pr edit --add-label CI-published-bottle-commits "$PR"
- name: Enable automerge
run: gh pr merge --auto --merge --delete-branch --match-head-commit "$SHA" "$PR"
env:
GH_TOKEN: ${{secrets.HOMEBREW_GITHUB_PUBLIC_REPO_TOKEN}}
PR: ${{steps.create-pr.outputs.pull_number}}
SHA: ${{steps.create-pr.outputs.head_sha}}
- name: Approve PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR: ${{ steps.create-pr.outputs.pull_number }}
run: gh pr review --approve "$PR"
comment:
permissions:
issues: write # for Homebrew/actions/post-comment
pull-requests: write # for Homebrew/actions/post-comment
needs: [bottle, upload]
if: failure() && inputs.issue > 0
runs-on: ubuntu-latest
steps:
- name: Post comment on failure
uses: Homebrew/actions/post-comment@master
with:
token: ${{secrets.GITHUB_TOKEN}}
issue: ${{inputs.issue}}
body: ":x: @${{github.actor}} bottle request for ${{inputs.formula}} [failed](${{env.RUN_URL}})."
bot_body: ":x: Bottle request for ${{inputs.formula}} [failed](${{env.RUN_URL}})."
bot: BrewTestBot