homebrew-core/.github/workflows/dispatch-rebottle.yml

224 lines
7.9 KiB
YAML

name: Dispatch rebottle (for all currently bottled OS versions)
run-name: Rebuild bottles of ${{ inputs.formula }}
on:
workflow_dispatch:
inputs:
formula:
description: Formula name
required: true
timeout:
description: "Build timeout (in minutes, default: 60 minutes)"
default: "60"
required: true
issue:
description: Issue number, where comment on failure would be posted
required: false
upload:
description: "Whether to upload built bottles or not (default: false)"
required: false
fail-fast:
description: "Whether to fail immediately on a single OS version failure (default: true)"
default: "true"
required: false
permissions:
contents: read
env:
HOMEBREW_DEVELOPER: 1
HOMEBREW_GITHUB_ACTIONS: 1
HOMEBREW_NO_AUTO_UPDATE: 1
jobs:
setup:
runs-on: ubuntu-22.04
container:
image: ghcr.io/homebrew/ubuntu22.04:master
outputs:
runners: ${{steps.determine-runners.outputs.runners}}
steps:
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Determine runners
id: determine-runners
run: brew determine-rebottle-runners "${{github.event.inputs.formula}}" "${{github.event.inputs.timeout}}"
bottle:
needs: setup
strategy:
matrix:
include: ${{fromJson(needs.setup.outputs.runners)}}
fail-fast: ${{fromJson(github.event.inputs.fail-fast)}}
runs-on: ${{matrix.runner}}
container: ${{matrix.container}}
timeout-minutes: ${{fromJson(github.event.inputs.timeout)}}
defaults:
run:
working-directory: ${{matrix.workdir || github.workspace}}
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
steps:
- name: ${{github.event.inputs.formula}}
id: print_details
run: |
echo sender=${{github.event.sender.login}}
echo formula=${{github.event.inputs.formula}}
echo timeout=${{github.event.inputs.timeout}}
echo issue=${{github.event.inputs.issue}}
echo upload=${{github.event.inputs.upload}}
- name: Set environment variables
if: runner.os == 'macOS'
run: |
echo 'PATH=/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin' >> $GITHUB_ENV
# TODO: remove the line below once set in the runner .env file
echo 'GITHUB_ACTIONS_HOMEBREW_SELF_HOSTED=1' >> $GITHUB_ENV
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
- run: brew test-bot --only-cleanup-before
- run: brew test-bot --only-setup
- name: Run brew test-bot --only-formulae --only-json-tab --skip-online-checks --skip-dependents
env:
HOMEBREW_GITHUB_API_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
mkdir bottles
cd bottles
brew test-bot --only-formulae --only-json-tab --skip-online-checks --skip-dependents ${{github.event.inputs.formula}}
- name: Failures summary for brew test-bot --only-formulae
if: always()
uses: Homebrew/actions/failures-summary-and-bottle-result@master
with:
workdir: ${{matrix.workdir || github.workspace}}
result_path: bottles/steps_output.txt
step_name: 'Build summary on ${{ matrix.runner }}'
- name: Output brew linkage result
if: always()
uses: Homebrew/actions/failures-summary-and-bottle-result@master
with:
workdir: ${{matrix.workdir || github.workspace}}
result_path: bottles/linkage_output.txt
step_name: '`brew linkage` output on ${{ matrix.runner }}'
- name: Output brew bottle result
if: always()
uses: Homebrew/actions/failures-summary-and-bottle-result@master
with:
workdir: ${{matrix.workdir || github.workspace}}
result_path: bottles/bottle_output.txt
step_name: '`brew bottle` output on ${{ matrix.runner }}'
- name: Upload logs
if: failure()
uses: actions/upload-artifact@main
with:
name: logs
path: ${{matrix.workdir || github.workspace}}/bottles/logs
- name: Delete logs and home
if: always()
run: |
rm -rvf bottles/logs
rm -rvf bottles/home
rm -rvf bottles/failed
- name: Count bottles
id: bottles
if: always()
run: |
cd bottles
count=$(ls *.json | wc -l | xargs echo -n)
echo "$count bottles"
echo "::set-output name=count::$count"
- name: Upload bottles to GitHub Actions
if: always() && steps.bottles.outputs.count > 0
uses: actions/upload-artifact@main
with:
name: bottles
path: ${{matrix.workdir || github.workspace}}/bottles
- name: Post cleanup
if: always()
run: |
brew test-bot --only-cleanup-after
rm -rvf bottles
- name: Post comment on failure
if: ${{!success() && github.event.inputs.issue > 0}}
uses: Homebrew/actions/post-comment@master
with:
token: ${{secrets.HOMEBREW_GITHUB_PUBLIC_REPO_TOKEN}}
issue: ${{github.event.inputs.issue}}
body: ":x: @${{github.actor}} bottle request for ${{github.event.inputs.formula}} [failed](${{github.event.repository.html_url}}/actions/runs/${{github.run_id}})."
bot_body: ":x: Bottle request for ${{github.event.inputs.formula}} [failed](${{github.event.repository.html_url}}/actions/runs/${{github.run_id}})."
bot: BrewTestBot
upload:
permissions:
issues: write # for Homebrew/actions/post-comment
contents: write # for Homebrew/actions/git-try-push
packages: write # for brew pr-upload
runs-on: ubuntu-22.04
needs: bottle
if: github.event.inputs.upload
env:
HOMEBREW_SIMULATE_MACOS_ON_LINUX: 1
steps:
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Download bottles from GitHub Actions
uses: actions/download-artifact@main
with:
name: bottles
path: ~/bottles/
- name: Setup git
uses: Homebrew/actions/git-user-config@master
- name: Set up commit signing
uses: Homebrew/actions/setup-commit-signing@master
with:
signing_key: ${{ secrets.BREWTESTBOT_GPG_SIGNING_SUBKEY }}
- 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 <1589480+BrewTestBot@users.noreply.github.com>"
run: |
cd ~/bottles
brew pr-upload --verbose --committer="$BREWTESTBOT_NAME_EMAIL" --root-url="https://ghcr.io/v2/homebrew/core" --debug
- name: Push commits
uses: Homebrew/actions/git-try-push@master
with:
token: ${{secrets.HOMEBREW_GITHUB_PUBLIC_REPO_TOKEN}}
env:
GIT_COMMITTER_NAME: BrewTestBot
GIT_COMMITTER_EMAIL: 1589480+BrewTestBot@users.noreply.github.com
HOMEBREW_GPG_PASSPHRASE: ${{ secrets.BREWTESTBOT_GPG_SIGNING_SUBKEY_PASSPHRASE }}
- name: Post comment on failure
if: ${{!success() && github.event.inputs.issue > 0}}
uses: Homebrew/actions/post-comment@master
with:
token: ${{secrets.HOMEBREW_GITHUB_PUBLIC_REPO_TOKEN}}
issue: ${{github.event.inputs.issue}}
body: ":x: @${{github.actor}} bottle request for ${{github.event.inputs.formula}} [failed](${{github.event.repository.html_url}}/actions/runs/${{github.run_id}})."
bot_body: ":x: Bottle request for ${{github.event.inputs.formula}} [failed](${{github.event.repository.html_url}}/actions/runs/${{github.run_id}})."
bot: BrewTestBot