# Set up Hayabuild for this repository

You are setting up Hayabuild (https://haya.build), a build service made for coding agents. It runs this repository's
GitHub Actions jobs that need a Mac on warm Apple-silicon Macs with a shared compilation cache; jobs that need no Mac
stay where they are. The workflows stay as they are; only where they run changes. Explain each step to the person in a sentence,
stop where a step says so, and never ask the person to paste a secret into the chat.

## 1. Connect

1. Add the Hayabuild plugin, or the MCP server `https://api.haya.build/mcp`, to this agent. The person signs in once
   with their Chekusu account in the browser window that opens. Check it works with `ci_capacity`.
2. Ask the person to install the **Hayabuild GitHub App** for this repository:
   https://github.com/apps/hayabuild/installations/select_target (they choose which repositories). Wait until they say it is done;
   `ci_capacity` then lists the repository.

## 2. Point the workflows at Hayabuild

Read `.github/workflows/*.yml`. In each job, change only `runs-on`:

| was | becomes |
| --- | --- |
| `macos-latest`, `macos-15`, `macos-26`, `macos-*-xlarge`, a self-hosted Mac label | `hayabuild-macos` |

Keep everything else: steps, secrets, matrices, caches, artifacts. A `matrix` that lists runner names gets the new
labels in the matrix. Leave Linux (`ubuntu-*`) and Windows jobs alone: Hayabuild builds on Macs only. Then:

- Remove steps that only exist to warm caches for Xcode, if the person agrees: `actions/cache` of `DerivedData`,
  `SourcePackages` or `~/Library/Caches/org.swift.swiftpm`. Hayabuild keeps those warm on the Mac (Xcode's compilation
  cache, a fixed DerivedData, Swift package and Go caches). Keep caches of anything else.
- `maxim-lobanov/setup-xcode` and `xcode-select` steps keep working; `ci_capacity` lists the Xcode versions the Macs have.
- A job that uses `sudo` to change the machine itself (GUI settings, TCC privacy permissions, trusted certificates in
  the System keychain), or that refuses to run outside GitHub's hosted Macs, gets `runs-on: [hayabuild-macos, vm]`: a
  fresh macOS VM of its own, thrown away after the job, with passwordless `sudo`. Such a script can check
  `HAYABUILD_DISPOSABLE_VM=1` alongside `RUNNER_ENVIRONMENT=github-hosted`; the user there is `admin`, not `runner`.

Open a pull request with the change, say in it which jobs moved, and watch its checks: they run on Hayabuild now.
Report how long each job took next to its previous run on GitHub (the run history of the same workflow).

## 3. Releases to TestFlight (only if the person ships an app)

If a workflow already uploads with fastlane or `xcrun altool`, it keeps working after step 2. To let agents ship
builds directly instead:

1. Call `ci_asc_connect`. It returns a one-time link; send it to the person. They upload their App Store Connect API key
   (.p8, Admin or App Manager) in their own browser; Hayabuild checks it with Apple and stores it encrypted. Never
   ask for the .p8 or its Key ID in the chat. `ci_asc_status` tells you when it is done.
2. `ci_release_add_app` with the scheme, bundle id and the key (needs the person's approval).
3. In the panel (https://app.haya.build), the person turns on "agents may upload" for that app if they want you to.
4. `ci_release` archives, signs with Xcode cloud signing and uploads to TestFlight.

## 4. Builds without a workflow

For a quick build or test outside GitHub Actions, `ci_run` runs any command on a Mac for this repository at any commit
and `ci_wait` / `ci_logs` follow it. Use it to try a fix before pushing.

## 5. Report

Finish with a short summary: the jobs you moved and to which label, what you removed, the first times on Hayabuild next
to GitHub's, and anything the person still has to do (install the app, merge the pull request, the ASC key).
