Skip to content

Sign release builds in a protected release job - #25

Merged
mrhegemon merged 4 commits into
mainfrom
ci/release-signing
Nov 14, 2026
Merged

mrhegemon merged 4 commits into
mainfrom
ci/release-signing

Conversation

@mrhegemon

Copy link
Copy Markdown
Member

Summary

CI can now sign Quest builds with the release key without exposing the key's passwords, and it can activate a Unity Personal licence.

During a signed build, Unity 6000.6.9f1 writes the keystore and key passwords in plain text into Library/Bee and into compiled build scripts in Gradle's home. On main, quest-build.yml signs in the same job that saves the Library cache, and anyone who can open a pull request can read this public repository's Actions caches. Adding the ANDROID_* secrets today would therefore publish the passwords. With this PR, only a separate release job signs. It runs in a protected release environment and never saves the Library or Gradle cache.

  • Three commits on main @ 2147965: 103ff8b, 461196e and 8f15f92. Merge them together. 461196e on its own moves to the new GameCI actions but keeps main's single job that both signs and saves the cache.
  • Add the ANDROID_* secrets only after this is merged.
  • This PR changes Assets/, so its own Unity Tests check is the first run of the new Unity activation. That check needs UNITY_EMAIL and UNITY_PASSWORD, set as described in step 3 below.

What changed

103ff8b build(android): one set of signing variables

  • CommandLineBuild.BuildAndroidQuest reads ANDROID_KEYSTORE_NAME, ANDROID_KEYSTORE_PASS, ANDROID_KEYALIAS_NAME and ANDROID_KEYALIAS_PASS. These are the names GameCI passes into its build container, so local and CI builds read the same variables. A relative keystore path is taken from the project folder.
  • -release still fails unless all four are set and the keystore exists. It now also fails while a build profile is active.
  • versionCode comes only from Player Settings > Version (bundleVersion), as MAJOR×1000000 + MINOR×1000 + PATCH.
  • VERSION_CODE, VERSION_NAME and the old KEYSTORE_PATH, KEYSTORE_PASS, KEY_ALIAS and KEY_PASS are no longer read. The build warns when one is set, and a -release build that has only the old names fails and names the new ones.
  • After a signed build, every file under Library/Bee that holds either password is deleted. Only file names are logged. Debug-signed builds are unchanged.

461196e ci: Unity Personal activation

  • The Quest build moves to unity-builder v6.0.0 and Unity Tests to unity-test-runner v4.4.0, both with game-ci/cli v0.1.72. The CLI activates Unity Personal from UNITY_EMAIL and UNITY_PASSWORD, plus UNITY_SERIAL for a paid seat.
  • A Personal .ulf no longer activates 6000.6 in CI, so UNITY_LICENSE is no longer passed.
  • The Quest build stops early when UNITY_PASSWORD contains " or \, which GameCI cannot pass to docker. It also removes stale editor PID files from a restored Library.

8f15f92 ci(quest): sign only in a gated release job

  • A plan job reads the Unity and app versions and starts one of two build jobs. A tag must be v<bundleVersion> and on main.

  • debug job: manual runs on any branch. It never references the ANDROID_* secrets, signs with a debug key made for the run, and is the only job that saves the Library cache.

  • release job: v* tags on main, manual runs on main with release ticked, and manual runs on a v* tag.

    • It runs in the release environment and requires both passwords to be 20 or more letters and digits. It builds with -release.
    • It restores the Library cache read-only. It never saves a Library or Gradle cache and never uploads Library.
    • When the build step ends, also after a failure, it deletes the decoded keystore, Library/Bee and ~/.gradle. GameCI mounts the runner's home folder as the container's /root, so Gradle's home ends up in ~/.gradle.
    • It then searches the workspace and the runner's home folder for either password and fails before upload if a file still holds one. The log names files only.
  • package=aab builds an App Bundle.

  • .github/scripts/check-quest-package.sh checks each package with the Unity image's own tools:

    • versionCode, versionName and target API level 34;
    • an APK must verify with a v2 signature;
    • a release package must not carry the Android debug certificate.

    The run summary shows the certificate's SHA-256.

  • A tag build attaches the package and its checksum to a draft GitHub Release.

  • The README, docs/qa-ci.md and docs/SIDELOAD.md cover the jobs, the release environment, the secrets, local signed builds and how to release a version.

Verification

Local checks used Unity 6000.6.9f1 on Windows with the Android target. The C# in this PR is byte-identical to what was tested.

  • EditMode tests: 131 of 131 passed, 25 of them in AndroidReleaseSettingsTests.
  • Signed build: one -release build with a throwaway key made like the release keystore (PKCS12, RSA 4096, alias companion-scan). The passwords came from the environment, with a temporary GRADLE_USER_HOME. The build exited 0 after 9.2 minutes and produced a 79.6 MB APK.
    • apksigner verifies the APK with a v2 signature (no v1 or v3). The signer is the throwaway key, not the Android debug certificate.
    • aapt2 reports versionCode 1000, versionName 0.1.0 and targetSdkVersion 34.
    • The build checked 9,726 files under Library/Bee in 59 seconds. It deleted the 7 that held the password: the generated launcher/build.gradle files and Bee's build graph and inputs.
    • A later search of 62,294 files in the project and the Gradle home found the password in only 3 files: compiled build-script classes in the temporary Gradle home. That is why the README uses a throwaway GRADLE_USER_HOME and the release job deletes ~/.gradle. The search found no copy of the keystore file.

Workflows and scripts:

  • actionlint: version 1.7.12 with shellcheck 0.11.0 found nothing in the four workflows.
  • Cleanup step: run against fake runner folders, all 9 cases behaved as expected.
    • It fails when a password is left in a text or binary file, when the workspace is outside the home folder, when only the key password is left, and when grep errors and also finds a match.
    • It passes on a clean run, a skipped build, empty passwords and a grep error without a match (with a warning).
    • No password appeared in its output or on any of the 16 recorded sudo command lines.
  • Package check: check-quest-package.sh behaved as expected in 10 local cases: an APK, plus synthetic signed and unsigned AABs.

Not verified

  • Nothing here has run on GitHub Actions. That covers both Quest build jobs, the package check and the cleanup step on a runner, and unity-test-runner v4.4.0 on the self-hosted runner. Unity Personal activation through game-ci/cli is untested.
  • No AAB was built. The check script's AAB path was tested with synthetic bundles only.
  • The signed build ran on Windows, while CI builds on Linux in GameCI's container.
  • On Windows, the build's own cleanup could not read 5 files deep in Library/Bee, whose paths are over 260 characters. It warns, and the README says to delete Library/Bee in that case. The release job deletes Library/Bee outright.
  • The release job's search finds plain-text copies only, not copies inside compressed files.
  • unity-builder v6 saves one cache entry in the release job: its own game-ci CLI binary. It is written before Unity starts and holds no secrets. Where the workflow comment and docs/qa-ci.md say the job "never saves a cache", read "no Library or Gradle cache".
  • game-ci/cli is pinned by release tag (v0.1.72), not by commit, and it handles the release key in the release job. Approving a release run trusts that release.
  • No release-signed build has been installed on a headset.

Owner actions after merge

  1. Create the release environment before any release run, because GitHub creates a missing environment without protection. Go to Settings → Environments → New environment and name it release. Add required reviewers, and limit deployment branches and tags to main and v*.

  2. Store the four signing secrets in that environment, not as repository secrets: a workflow edited on any branch can read repository secrets. The README calls this optional; do it anyway. Use gh secret set <name> --env release for each one:

    • ANDROID_KEYSTORE_BASE64: the release keystore, base64 on one line;
    • ANDROID_KEYSTORE_PASS;
    • ANDROID_KEYALIAS_PASS: the same password, in a PKCS12 keystore;
    • ANDROID_KEYALIAS_NAME: companion-scan.

    Both passwords must be 20 or more letters and digits.

  3. Set up the Unity licence. Set UNITY_EMAIL and UNITY_PASSWORD for a Unity ID kept for CI. It must sign in with a password and have two-factor authentication off, and its password must not contain " or \. Add UNITY_SERIAL only for a paid seat, and delete UNITY_LICENSE.

  4. Optional: add a tag ruleset that lets only maintainers create v* tags.

  5. Run the first builds. Run a debug build of main (gh workflow run quest-build.yml --ref main) to check activation and fill the cache. Then run one release build (-f release=true) and approve it. Check that the certificate SHA-256 in the run summary matches your release keystore before you push the first v* tag.

🤖 Generated with Claude Code

mrhegemon and others added 3 commits November 13, 2026 11:42
…bles

CommandLineBuild.BuildAndroidQuest now reads the signing variables that
GameCI passes into its build container, so local and CI builds use one set of
names: ANDROID_KEYSTORE_NAME (the keystore path; a relative path resolves
against the project folder, where GameCI decodes ANDROID_KEYSTORE_BASE64),
ANDROID_KEYSTORE_PASS, ANDROID_KEYALIAS_NAME and ANDROID_KEYALIAS_PASS.

- -release still fails unless all four are set and the keystore exists. It
  now also fails while a build profile is active, because Unity would then
  read and write the profile's copy of Player Settings.
- versionCode has one source: Player Settings > Version (bundleVersion), as
  MAJOR*1000000 + MINOR*1000 + PATCH. VERSION_CODE and VERSION_NAME are no
  longer read.
- KEYSTORE_PATH, KEYSTORE_PASS, KEY_ALIAS and KEY_PASS are retired rather
  than kept as fallbacks: the build warns when one is set, and a -release
  build that has only those fails and names the replacements.
- After a signed build, every file under Library/Bee in which Unity's Gradle
  export left a password in plain text is deleted; only file names are
  logged.
- Debug-signed builds are unchanged.

The README documents signed APK and AAB builds from the command line with a
temporary GRADLE_USER_HOME, how to check the signature, and the release
keystore of the contract (companion-scan-release.p12, PKCS12, RSA 4096,
alias companion-scan).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
unity-builder v5.0.1 and unity-test-runner v4.3.2 activate only a paid seat
with a serial key, and a Unity Personal .ulf no longer activates Unity 6000.6
in CI. Move both Unity workflows to unity-builder v6.0.0 and
unity-test-runner v4.4.0 with game-ci/cli pinned to v0.1.72, which activates
Personal from UNITY_EMAIL and UNITY_PASSWORD, plus UNITY_SERIAL for a paid
seat.

- UNITY_LICENSE is no longer passed. The Quest APK Build warns while it is
  set, and stops early when UNITY_PASSWORD holds " or \, which GameCI cannot
  pass to docker.
- The Quest APK Build removes stale editor PID files from a restored Library
  before Unity starts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
During a signed build Unity 6000.6.9f1 writes the keystore and key passwords
in plain text into Library/Bee and into compiled build scripts in Gradle's
home, and anyone who can open a pull request can read this public
repository's Actions caches. quest-build.yml signed in the job that also
saved the Library cache, so setting the ANDROID_* secrets would have
published the passwords.

The workflow now has a plan job and two build jobs:

- debug: manual runs on a branch. It never references the ANDROID_* secrets,
  signs with a debug key made for the run, and is the only job that saves
  the Library cache.
- release: v* tags on main, and manual runs on main with "release" or on a v*
  tag. It runs in the "release" environment, requires the passwords to be at
  least 20 letters and digits, builds with -release, restores the Library
  cache read-only, and never saves a cache or uploads Library. When the build
  step ends, also after a failure, it deletes the decoded keystore,
  Library/Bee and $HOME/.gradle: game-ci/cli runs the editor container as
  root with the runner's home folder mounted as /root, so Gradle's home
  /root/.gradle is $HOME/.gradle on the runner. It then searches the
  workspace and the runner's home folder for both passwords in plain text
  (grep reads them on standard input; only file names are printed) and fails
  the job, before the package is uploaded, if a file still holds one.

Both jobs run CommandLineBuild.BuildAndroidQuest, so CI takes its version
from bundleVersion (a tag must be v<bundleVersion> and on main) and can build
an AAB (package=aab). .github/scripts/check-quest-package.sh checks the
package with the Unity image's tools: versionCode, versionName and target API
level 34; an APK must verify with a v2 signature; a release package must not
carry the Android debug certificate. The certificate SHA-256 goes into the
run summary.

The README describes the release environment to create first (required
reviewers, main and v* only, optionally the ANDROID_* secrets as environment
secrets), the two jobs, the cache rule, and how to release a version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ver retention (#29)

README.md conflicted in two places: keep this branch's release-build text
(signing from GameCI's environment names, versionCode from bundleVersion)
with the artifact names main's command-line build now writes,
Builds/Android/CompanionScan.apk and .aab. The signature-check commands in
the README and docs/SIDELOAD.md named the old CompanionCapture artifacts
too and are updated the same way. The workflows pick packages up by
dist/*.apk and dist/*.aab, so they need no change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mrhegemon
mrhegemon merged commit f687aa2 into main Nov 14, 2026
1 of 2 checks passed
@mrhegemon
mrhegemon deleted the ci/release-signing branch November 14, 2026 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant