diff --git a/.github/hack/brew-install-version.sh b/.github/hack/brew-install-version.sh new file mode 100755 index 00000000..fbd6028e --- /dev/null +++ b/.github/hack/brew-install-version.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# This script only works for formulas in the homebrew-core. +# It assumes the homebrew-core has been checked out into ./homebrew-core. +# It only needs commit messages, so the checkout can be filtered with tree:0. + +set -eu -o pipefail + +FORMULA=$1 +VERSION=$2 + +export HOMEBREW_NO_AUTO_UPDATE=1 +export HOMEBREW_NO_INSTALL_UPGRADE=1 +export HOMEBREW_NO_INSTALL_CLEANUP=1 + +TAP=lima/tap +if ! brew tap | grep -q "^${TAP}\$"; then + brew tap-new "$TAP" +fi + +# Get the latest commit id for the commit that updated this bottle +SHA=$(git -C homebrew-core log --max-count 1 --grep "^${FORMULA}: update ${VERSION} bottle" --format="%H") +if [[ -z $SHA ]]; then + echo "${FORMULA} ${VERSION} not found" + exit 1 +fi + +OUTPUT="$(brew --repo "$TAP")/Formula/${FORMULA}.rb" +RAW="https://raw.githubusercontent.com/Homebrew/homebrew-core" +curl -s "${RAW}/${SHA}/Formula/${FORMULA::1}/${FORMULA}.rb" -o "$OUTPUT" + +if brew ls -1 | grep -q "^${FORMULA}\$"; then + brew uninstall "$FORMULA" --ignore-dependencies +fi +brew install "${TAP}/${FORMULA}" diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index d89e95c1..648addf3 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -32,12 +32,24 @@ jobs: with: go-version: "1.23" + - name: Fetch homebrew-core commit messages + uses: actions/checkout@v4 + with: + # needed by ./hack/brew-install-version.sh + repository: homebrew/homebrew-core + path: homebrew-core + fetch-depth: 0 + filter: tree:0 + - name: Install CLI deps env: HOMEBREW_NO_AUTO_UPDATE: "1" + HOMEBREW_NO_INSTALL_UPGRADE: "1" HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: "1" run: | brew install --overwrite python@3.12 kubectl docker coreutils lima + brew uninstall --ignore-dependencies qemu + ./.github/hack/brew-install-version.sh qemu 8.2.1 - name: Build and Install run: make && sudo make install @@ -63,7 +75,6 @@ jobs: kubernetes-containerd: runs-on: macos-13 - needs: kubernetes-docker steps: - uses: actions/checkout@v4 @@ -72,12 +83,24 @@ jobs: with: go-version: "1.23" + - name: Fetch homebrew-core commit messages + uses: actions/checkout@v4 + with: + # needed by ./hack/brew-install-version.sh + repository: homebrew/homebrew-core + path: homebrew-core + fetch-depth: 0 + filter: tree:0 + - name: Install CLI deps env: HOMEBREW_NO_AUTO_UPDATE: "1" + HOMEBREW_NO_INSTALL_UPGRADE: "1" HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: "1" run: | brew install --overwrite python@3.12 kubectl docker coreutils lima + brew uninstall --ignore-dependencies qemu + ./.github/hack/brew-install-version.sh qemu 8.2.1 - name: Build and Install run: make && sudo make install @@ -103,7 +126,6 @@ jobs: docker: runs-on: macos-13 - needs: kubernetes-containerd steps: - uses: actions/checkout@v4 @@ -112,12 +134,24 @@ jobs: with: go-version: "1.23" + - name: Fetch homebrew-core commit messages + uses: actions/checkout@v4 + with: + # needed by ./hack/brew-install-version.sh + repository: homebrew/homebrew-core + path: homebrew-core + fetch-depth: 0 + filter: tree:0 + - name: Install CLI deps env: HOMEBREW_NO_AUTO_UPDATE: "1" + HOMEBREW_NO_INSTALL_UPGRADE: "1" HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: "1" run: | brew install --overwrite python@3.12 kubectl docker coreutils lima + brew uninstall --ignore-dependencies qemu + ./.github/hack/brew-install-version.sh qemu 8.2.1 - name: Build and Install run: make && sudo make install @@ -152,7 +186,6 @@ jobs: containerd: runs-on: macos-13 - needs: docker steps: - uses: actions/checkout@v4 @@ -161,12 +194,24 @@ jobs: with: go-version: "1.23" + - name: Fetch homebrew-core commit messages + uses: actions/checkout@v4 + with: + # needed by ./hack/brew-install-version.sh + repository: homebrew/homebrew-core + path: homebrew-core + fetch-depth: 0 + filter: tree:0 + - name: Install CLI deps env: HOMEBREW_NO_AUTO_UPDATE: "1" + HOMEBREW_NO_INSTALL_UPGRADE: "1" HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: "1" run: | brew install --overwrite python@3.12 kubectl docker coreutils lima + brew uninstall --ignore-dependencies qemu + ./.github/hack/brew-install-version.sh qemu 8.2.1 - name: Build and Install run: make && sudo make install @@ -201,7 +246,6 @@ jobs: incus: runs-on: macos-13 - needs: containerd steps: - uses: actions/checkout@v4 @@ -210,12 +254,24 @@ jobs: with: go-version: "1.23" + - name: Fetch homebrew-core commit messages + uses: actions/checkout@v4 + with: + # needed by ./hack/brew-install-version.sh + repository: homebrew/homebrew-core + path: homebrew-core + fetch-depth: 0 + filter: tree:0 + - name: Install CLI deps env: HOMEBREW_NO_AUTO_UPDATE: "1" + HOMEBREW_NO_INSTALL_UPGRADE: "1" HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: "1" run: | brew install --overwrite python@3.12 kubectl docker coreutils lima incus + brew uninstall --ignore-dependencies qemu + ./.github/hack/brew-install-version.sh qemu 8.2.1 - name: Build and Install run: make && sudo make install