# Release and archive builds

> What the cache serves for xcodebuild archive and Release builds, and what it needs.

Source: https://warmbuild.dev/docs/release-builds/

**What you do**

1. Run the Action in the archive job, as in any other job.

   ``` title=".github/workflows/release.yml"
   - uses: warmbuild/action@v1.14.2
   ```
2. Let a Release build write first: a [write rule](https://warmbuild.dev/docs/security/#rules) for the archive's ref, or a Release build on the default branch.
3. Check the hits and misses in the job summary of the next archives.

**What you get**

The archive's compile tasks hit what an earlier Release build wrote; linking, signing, asset catalogs and dSYMs still run. How much it saves is not measured yet.

## Release and archive builds

The Action’s settings reach every configuration, so `xcodebuild archive` (Release, whole-module Swift) uses the cache when the archive job runs the Action. It saves less than in Debug.

- **What is cached:** the same compile tasks as in Debug: Swift (one task per module and architecture when compiling whole-module), C and Objective-C files, and explicit module builds. Linking, dSYMs, asset catalogs, storyboards, scripts, signing and the copy into the `.xcarchive` run every time.
- **The key includes the configuration:** the compiler keys each task on its full command line and inputs, so `-O`, `-wmo`, `DEBUG` and the other Release flags are part of it. Debug builds and pull requests never fill entries an archive can use; a Release build has to write them first.
- **Let it write:** only a run whose ref matches a [write rule](https://warmbuild.dev/docs/security/#rules) writes, by default the default branch. An archive job on tags or release branches needs a rule such as `refs/tags/*`, or a Release build on the default branch (`xcodebuild build -configuration Release -destination 'generic/platform=iOS'`) to fill the cache before it.
- **Whole-module means whole-module misses:** a change to any file of a module compiles that whole module again. Swift packages, frameworks and other modules the change did not touch can hit; an app that is one large module gains little after a change, and fully on a re-run of the same commit.
- **Same toolchain:** the archive must run on the same Xcode as the job that wrote, like every build.

### Not measured yet

- How many tasks a real archive hits.
- Whether a plain Release build fills everything an archive needs.
- Whether runners with different core counts share whole-module entries.

The job summary counts the cache’s hits and misses, so the first two archives after a Release build has written show where you stand.
