build-macos-image #65
This file contains hidden or 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: build-macos-image | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| macos: | |
| description: "macOS version to build (tahoe=26, the last Intel macOS; sequoia=15)" | |
| required: true | |
| type: choice | |
| default: tahoe | |
| options: | |
| - tahoe | |
| - sequoia | |
| stage: | |
| description: "boot | install | setup | desktop (WIP, blocked on SA) | verify | slim (reclaim stale clusters, repush same tag)" | |
| required: true | |
| default: "boot" | |
| version_tag: | |
| description: "Override the ghcr image tag (blank => 26 for tahoe, 15 for sequoia)" | |
| required: false | |
| default: "" | |
| disk_size: | |
| description: "Disk image size" | |
| required: true | |
| default: "80G" | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 180 | |
| env: | |
| STAGE: ${{ github.event.inputs.stage }} | |
| DISK_SIZE: ${{ github.event.inputs.disk_size }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Resolve macOS target (shortname + ghcr repo/tag + qcow2 name) | |
| run: | | |
| case "${{ github.event.inputs.macos }}" in | |
| sequoia) SHORT=sequoia; DEF_TAG=15; NAME=macos-sequoia-15.qcow2 ;; | |
| tahoe|*) SHORT=tahoe; DEF_TAG=26; NAME=macos-tahoe-26.qcow2 ;; | |
| esac | |
| TAG="${{ github.event.inputs.version_tag }}"; [ -z "$TAG" ] && TAG="$DEF_TAG" | |
| { | |
| echo "MACOS_SHORTNAME=$SHORT" | |
| echo "GHCR_REPO=ghcr.io/cocoonstack/cocoon-macos/$SHORT" | |
| echo "GHCR_TAG=$TAG" | |
| echo "QCOW2_NAME=$NAME" | |
| } >> "$GITHUB_ENV" | |
| echo "building $SHORT (tag $TAG) -> ghcr.io/cocoonstack/cocoon-macos/$SHORT:$TAG" | |
| - name: Free disk space | |
| run: | | |
| sudo rm -rf /usr/share/dotnet /usr/local/share/boost /opt/ghc \ | |
| /usr/local/lib/android /opt/hostedtoolcache/CodeQL | |
| df -h / | |
| - name: Install QEMU + tools | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y --no-install-recommends \ | |
| qemu-system-x86 qemu-utils dmg2img socat netpbm python3-pip tesseract-ocr python3-pil sshpass | |
| - name: Verify KVM (load-bearing — gates the whole build) | |
| run: | | |
| ls -l /dev/kvm || { echo "::error::/dev/kvm absent on this runner"; exit 1; } | |
| sudo apt-get install -y cpu-checker || true | |
| kvm-ok || true | |
| - name: Log in to ghcr | |
| if: ${{ github.event.inputs.stage != 'boot' }} | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Install oras | |
| if: ${{ github.event.inputs.stage != 'boot' }} | |
| run: | | |
| ORAS_VERSION=1.2.0 | |
| curl -fsSL "https://github.com/oras-project/oras/releases/download/v${ORAS_VERSION}/oras_${ORAS_VERSION}_linux_amd64.tar.gz" \ | |
| | sudo tar -xz -C /usr/local/bin oras | |
| oras version | |
| - name: Build (stage=${{ github.event.inputs.stage }}) | |
| run: bash scripts/build-qemu-macos.sh | |
| - name: Upload artifacts (screenshots / logs) | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: macos-build-${{ github.event.inputs.macos }}-${{ github.event.inputs.stage }} | |
| path: work/qemu-build/artifacts/ | |
| if-no-files-found: warn |