diff --git a/.github/workflows/game-build.yml b/.github/workflows/game-build.yml new file mode 100644 index 000000000..65acf1b28 --- /dev/null +++ b/.github/workflows/game-build.yml @@ -0,0 +1,274 @@ +name: game build +# Builds the game for every platform from `ref`: the Java exporters, then Linux and the Linux server and Windows on +# GitHub, macOS on the Mac mini's runner with a 1500-frame offscreen run of a new world (smoke-test.json). Called by +# release.yml (the releases) and nightly-build.yml (the opt-in Nightly), always from main's copy of this file: the +# caller's commit, never the one being built. It holds no secrets: signing the checksums is the callers' own job, +# which never runs what this one built. See docs/release-flow.md. +on: + workflow_call: + inputs: + ref: + description: The commit to build + type: string + required: true + version: + description: The version built in (HORIZON_VERSION), e.g. 0.2.81 or nightly-2026-10-28 + type: string + required: true + nightly: + description: A nightly's " " (HORIZON_NIGHTLY), shown by the game; empty for a release + type: string + default: '' + developer_id: + description: Sign the macOS programs with Developer ID and notarize the zip (the runner's keychain) + type: boolean + default: true +permissions: + contents: read +jobs: + exporters: + # This runner holds the maintainer's own pinned Minecraft jars. Only our classes leave it. + runs-on: ${{ vars.MAC_RUNNER || 'ludovics-mac-mini' }} + # Three full preparations (two isolated, one batched) besides the compile. + timeout-minutes: 60 + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref }} + persist-credentials: false + clean: true + - uses: dtolnay/rust-toolchain@stable + - run: bash tools/ci/runner-env.sh + - run: bash tools/ci/vanilla-data.sh + - name: Compile and validate original exporters against the pinned jars + shell: bash + run: | + set -euo pipefail + # target/ is gone after the clean checkout, and vanilla-data.sh builds the preparer only when it + # prepares afresh. + cargo build --release --locked -p horizon-prepare + # Compiled here, never taken from the runner's shared preparations: pull requests' parity jobs + # write those (vanilla-data.sh links .local/exporters to them). + rm -rf .local/exporters + bundle=$(target/release/horizon-prepare compile-exporters --root "$PWD" | tail -1) + mkdir -p exporters + cp -R "$bundle/server" "$bundle/client" "$bundle/manifest.json" exporters/ + # Only our classes and their manifest leave this runner. + stray=$(find exporters -type f ! -path exporters/manifest.json \ + ! \( -name '*.class' \( -path 'exporters/server/dev/horizonlab/parity/*' -o -path 'exporters/client/dev/horizonlab/parity/*' \) \)) + [ -z "$stray" ] || { echo "::error::not one of our classes: $stray"; exit 1; } + python3 tools/check_prepare_exporters.py --binary target/release/horizon-prepare + - uses: actions/upload-artifact@v4 + with: + name: original-exporters + path: exporters/ + if-no-files-found: error + retention-days: 3 + + build: + needs: exporters + name: build ${{ matrix.name }} + strategy: + fail-fast: false + matrix: + include: + - name: linux + os: ubuntu-22.04 + dir: horizon-linux-x86_64 + asset: horizon-linux-x86_64.tar.gz + # The server build too: packaging/server/install.sh installs it on Linux. + server_dir: horizon-server-linux-x86_64 + server_asset: horizon-server-linux-x86_64.tar.gz + - name: windows + os: windows-latest + dir: horizon-windows-x64 + asset: horizon-windows-x64.zip + exe: .exe + # The C runtime linked in, so the game runs without the Visual C++ redistributable. + rustflags: -C target-feature=+crt-static + - name: macos + mac: true + dir: horizon-macos-arm64 + asset: horizon-macos-arm64.zip + runs-on: ${{ matrix.mac && (vars.MAC_RUNNER || 'ludovics-mac-mini') || matrix.os }} + # Notarizing the zip can take a few minutes. + timeout-minutes: ${{ matrix.mac && 60 || 40 }} + env: + RUSTFLAGS: ${{ matrix.rustflags }} + # The release's version, built in (horizon_core::release): --version, user agents, crash reports and + # telemetry say it. No version-bump commits. + HORIZON_VERSION: ${{ inputs.version }} + # A nightly's date and commit ("2026-10-28 0c02067"), which the game shows; empty for a release. + HORIZON_NIGHTLY: ${{ inputs.nightly }} + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref }} + persist-credentials: false + # Always from a clean checkout, the Mac mini's runner too: its work folder is shared with pull requests' + # parity jobs, and nothing they leave (target/, an untracked .cargo/config.toml, a build script's output) + # may end up in a release. target/ is rebuilt from scratch; .local/ is relinked by vanilla-data.sh, which + # keeps its preparations outside the checkout. + clean: true + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + if: runner.environment == 'github-hosted' + with: + shared-key: release-${{ matrix.name }} + - name: ALSA and udev headers + if: runner.os == 'Linux' + run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libasound2-dev libudev-dev + - name: Build the client, horizon-ctl, horizon-prepare and horizon-server + # `horizon-client/mods`: every released game runs code mods (the feature is off in dev builds). + run: cargo build --release --locked --features horizon-client/mods -p horizon-client --bin horizon-client --bin horizon-ctl -p horizon-prepare --bin horizon-prepare -p horizon-server --bin horizon-server + - name: Every program the release folder takes was built + run: | + for binary in horizon-client horizon-ctl horizon-prepare horizon-server; do + test -f "target/release/$binary${{ matrix.exe }}" || { echo "::error::target/release/$binary${{ matrix.exe }} is missing"; exit 1; } + done + - name: The signing keychain, unlocked + if: runner.os == 'macOS' && vars.MACOS_SIGN_IDENTITY != '' && inputs.developer_id + env: + MACOS_SIGN_IDENTITY: ${{ vars.MACOS_SIGN_IDENTITY }} + run: packaging/macos/keychain.sh unlock + - name: Signed with Developer ID and the hardened runtime + # Before the checks below, so they run the programs as players will. + if: runner.os == 'macOS' && vars.MACOS_SIGN_IDENTITY != '' && inputs.developer_id + env: + MACOS_SIGN_IDENTITY: ${{ vars.MACOS_SIGN_IDENTITY }} + run: | + for binary in horizon-client horizon-ctl horizon-prepare horizon-server; do + codesign --force --options runtime --timestamp --keychain "$MACOS_SIGN_KEYCHAIN" \ + --identifier "dev.horizon.${binary#horizon-}" --sign "$MACOS_SIGN_IDENTITY" "target/release/$binary" + codesign --verify --strict --verbose=2 "target/release/$binary" + done + - name: Only system libraries + # Windows: no non-system DLL (a "DLL not found" dialog on some players' machines). Linux: the standard + # loader and libraries every desktop distribution has. macOS: only the system's own libraries. + run: | + for binary in horizon-client horizon-ctl horizon-prepare horizon-server; do + file="target/release/$binary${{ matrix.exe }}" + if [[ "$RUNNER_OS" == macOS ]]; then + others=$(otool -L "$file" | tail -n +2 | awk '{print $1}' | grep -v -E '^(/usr/lib/|/System/Library/)' || true) + [[ -z "$others" ]] || { echo "::error::$binary links $others"; exit 1; } + else + ${{ runner.os == 'Windows' && 'python' || 'python3' }} tools/check_imports.py "$file" + fi + done + - name: Every program starts + run: | + set -euo pipefail + bin=target/release + "$bin/horizon-client${{ matrix.exe }}" --help | grep -q -- '--resources' + "$bin/horizon-ctl${{ matrix.exe }}" --help > /dev/null + "$bin/horizon-prepare${{ matrix.exe }}" --help | grep -q -- '--minecraft-dir' + # The version is the release's. + for binary in horizon-prepare horizon-server; do + out=$("$bin/$binary${{ matrix.exe }}" --version | tr -d '\r') + echo "$out" + [[ "$out" == "$binary $HORIZON_VERSION" ]] || { echo "::error::expected $binary $HORIZON_VERSION"; exit 1; } + done + - name: Tools from the runner + if: runner.environment == 'self-hosted' + run: bash tools/ci/runner-env.sh + - name: Resources prepared from the runner's own Minecraft + if: runner.environment == 'self-hosted' + run: bash tools/ci/vanilla-data.sh + - name: The game runs (offscreen, a new world, 1500 frames) + if: runner.environment == 'self-hosted' + run: | + set -euo pipefail + # From a scratch folder: the game keeps its saves and options in the folder it starts in. + home="$RUNNER_TEMP/horizon-smoke" + rm -rf "$home" && mkdir -p "$home" + version=$(sed -n 's/.*"version": *"\([^"]*\)".*/\1/p' research-lock.json | head -1) + client="$PWD/target/release/horizon-client" + resources="$PWD/.local/horizon-client/$version" + (cd "$home" && HORIZON_HOME="$home" HORIZON_NO_AUDIO=1 "$client" --resources "$resources" --offscreen \ + --world smoke --seed 1 --render-distance 4 --world-frames 1500 --timeout-seconds 180 \ + --smoke-report "$home/smoke.json" > "$home/client.log" 2>&1) || { tail -40 "$home/client.log"; exit 1; } + python3 - "$home/smoke.json" <<'EOF' + import json, sys + report = json.load(open(sys.argv[1])) + print(json.dumps(report)) + if report.get("error") is not None or report.get("frames", 0) < 1500 or not report.get("chunks") \ + or not report.get("meshed_sections") or not report.get("player"): + sys.exit("the smoke run did not draw a world") + EOF + # Published with the release; the publish job checks it again before it publishes anything. + cp "$home/smoke.json" "$RUNNER_TEMP/smoke-test.json" + - uses: actions/upload-artifact@v4 + if: runner.environment == 'self-hosted' + with: + name: smoke-test.json + path: ${{ runner.temp }}/smoke-test.json + if-no-files-found: error + retention-days: 3 + - uses: actions/download-artifact@v4 + with: + name: original-exporters + path: exporters + - name: Package + run: | + set -euo pipefail + cargo run --locked -p xtask -- package "target/release/horizon-client${{ matrix.exe }}" "dist/${{ matrix.dir }}" + cd dist + rm -f "${{ matrix.asset }}" + case "${{ matrix.asset }}" in + *.tar.gz) tar czf "${{ matrix.asset }}" "${{ matrix.dir }}" ;; + *) if [[ "$RUNNER_OS" == Windows ]]; then 7z a -tzip "${{ matrix.asset }}" "${{ matrix.dir }}" > /dev/null + else + # Without resource forks and extended attributes: plain ditto adds an + # AppleDouble `._` file beside every file that has any. + ditto -c -k --norsrc --noextattr --noqtn --keepParent "${{ matrix.dir }}" "${{ matrix.asset }}" + if unzip -Z1 "${{ matrix.asset }}" | grep -E '(^|/)(\._|__MACOSX/)'; then + echo "::error::macOS metadata files in ${{ matrix.asset }}"; exit 1 + fi + fi ;; + esac + ls -l "${{ matrix.asset }}" + - name: Notarized + # A zip of programs can't be stapled: Gatekeeper asks Apple the first time each one runs. + if: runner.os == 'macOS' && vars.MACOS_SIGN_IDENTITY != '' && inputs.developer_id + run: | + for binary in horizon-client horizon-ctl horizon-prepare horizon-server; do + codesign --verify --strict "dist/${{ matrix.dir }}/$binary" + done + packaging/macos/notarize.sh "dist/${{ matrix.asset }}" + - uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.asset }} + path: dist/${{ matrix.asset }} + if-no-files-found: error + retention-days: 3 + - name: The server build (the game without sound or controllers, as horizon-engine) + if: matrix.server_asset + run: | + set -euo pipefail + # After the client is packaged: target/release/horizon-client is rebuilt without the audio and + # controllers features, so it needs neither libasound nor libudev (minimal server images lack them), + # and with code mods like the client. + cargo build --release --locked -p horizon-client --no-default-features --features mods --bin horizon-client + cargo run --locked -p xtask -- package-server target/release/horizon-client "dist/${{ matrix.server_dir }}" + folder="dist/${{ matrix.server_dir }}" + python3 tools/check_imports.py --server "$folder/horizon-engine" "$folder/horizon-server" "$folder/horizon-prepare" + "$folder/horizon-engine" --help | grep -q -- '--resources' + [[ "$("$folder/horizon-server" --version)" == "horizon-server $HORIZON_VERSION" ]] + cd dist + rm -f "${{ matrix.server_asset }}" + tar czf "${{ matrix.server_asset }}" "${{ matrix.server_dir }}" + ls -l "${{ matrix.server_asset }}" + - uses: actions/upload-artifact@v4 + if: matrix.server_asset + with: + name: ${{ matrix.server_asset }} + path: dist/${{ matrix.server_asset }} + if-no-files-found: error + retention-days: 3 + - name: The signing keychain, locked again + if: always() && runner.os == 'macOS' && vars.MACOS_SIGN_IDENTITY != '' && inputs.developer_id + run: packaging/macos/keychain.sh lock + diff --git a/.github/workflows/nightly-build.yml b/.github/workflows/nightly-build.yml new file mode 100644 index 000000000..d674d5992 --- /dev/null +++ b/.github/workflows/nightly-build.yml @@ -0,0 +1,166 @@ +name: nightly build +# The opt-in Nightly channel (docs/release-flow.md "Nightly"; Ludovic, 2026-10-27). Once a night it builds the newest +# union branch on origin (union/-: main plus pull requests the contribution gate proved together), or +# main when no union is newer, and publishes it as the `nightly` pre-release. Launchers install it only for players +# who turn Nightly on. The previous nightly stays a week as nightly-. +# +# Why the signing key never meets the union's code: +# - This file, game-build.yml and every script below run from main's copy: a schedule runs the default branch, and +# `uses: ./…` takes the caller's commit. The union's own .github/ is never read. +# - `build` (game-build.yml) checks out and compiles the union with no secrets: its token reads contents only and +# isn't kept in the checkout; the macOS programs are signed ad hoc (Developer ID needs the runner's keychain, +# which stays locked for nightlies). +# - `sign` is the only job with RELEASE_SIGNING_KEY. It checks out nothing but main's tools/ci/sign_release.sh, which +# runs the runner's sha256sum and OpenSSL over the archives: it hashes them, never runs them. The signed message +# names the channel ("horizon release nightly"), so a nightly's signature can't pass for a release's. +# - `publish` verifies the signature with main's horizon-release-sign, checks the smoke test, and only then moves +# the tag. Like sign, it never executes what build produced. +# gh workflow run "nightly build" # now (skips when the pick is the same commit as last night's) +# gh workflow run "nightly build" -f force=true # build and publish even if unchanged +# gh workflow run "nightly build" -f dry_run=true # build and sign with a throwaway key, publish nothing +on: + schedule: + - cron: '17 20 * * *' # 20:17 UTC: after the day's waves, before the 03:07 Paris parity audit takes the Mac mini + workflow_dispatch: + inputs: + force: + description: Build and publish even if tonight's pick is the commit already published + type: boolean + default: false + dry_run: + description: Build and sign with a throwaway key, publish nothing + type: boolean + default: false +permissions: + contents: read +concurrency: + group: nightly-build + cancel-in-progress: false +jobs: + pick: + runs-on: ubuntu-latest + timeout-minutes: 10 + outputs: + build: ${{ steps.pick.outputs.build }} + sha: ${{ steps.pick.outputs.sha }} + source: ${{ steps.pick.outputs.source }} + date: ${{ steps.pick.outputs.date }} + version: ${{ steps.pick.outputs.version }} + nightly: ${{ steps.pick.outputs.nightly }} + dry_run: ${{ steps.mode.outputs.dry_run }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + persist-credentials: false + - id: mode + # A dry run never publishes; a hand-started run off main is always one. + run: echo "dry_run=${{ github.event_name == 'workflow_dispatch' && (inputs.dry_run || github.ref != 'refs/heads/main') }}" >> "$GITHUB_OUTPUT" + - id: pick + env: + GH_TOKEN: ${{ github.token }} + FORCE: ${{ (inputs.force || steps.mode.outputs.dry_run == 'true') && 'yes' || '' }} + run: | + python3 tools/ci/nightly.py pick ${FORCE:+--force} | tee -a "$GITHUB_STEP_SUMMARY" + { echo; cat nightly-notes.md; } >> "$GITHUB_STEP_SUMMARY" + - uses: actions/upload-artifact@v4 + with: + name: nightly-notes + path: nightly-notes.md + retention-days: 3 + + build: + needs: pick + if: needs.pick.outputs.build == 'true' + uses: ./.github/workflows/game-build.yml + with: + ref: ${{ needs.pick.outputs.sha }} + version: ${{ needs.pick.outputs.version }} + nightly: ${{ needs.pick.outputs.nightly }} + developer_id: false + + sign: + needs: [pick, build] + runs-on: ubuntu-latest + timeout-minutes: 10 + # The key's only job: main's sign_release.sh hashes the archives and signs with the runner's OpenSSL. + environment: ${{ needs.pick.outputs.dry_run != 'true' && 'release' || '' }} + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: tools/ci/sign_release.sh + sparse-checkout-cone-mode: false + persist-credentials: false + - uses: actions/download-artifact@v4 + with: + path: dist + pattern: horizon-* + merge-multiple: true + - name: Sign the checksums (SHA256SUMS, SHA256SUMS.sig) for the nightly channel + env: + RELEASE_SIGNING_KEY: ${{ secrets.RELEASE_SIGNING_KEY }} + RELEASE_SIGNING_KEY_NEXT: ${{ secrets.RELEASE_SIGNING_KEY_NEXT }} + EPHEMERAL: ${{ needs.pick.outputs.dry_run == 'true' && 'yes' || '' }} + run: | + bash tools/ci/sign_release.sh nightly dist/horizon-linux-x86_64.tar.gz dist/horizon-windows-x64.zip \ + dist/horizon-macos-arm64.zip dist/horizon-server-linux-x86_64.tar.gz + - uses: actions/upload-artifact@v4 + with: + name: signature + path: dist/SHA256SUMS* + if-no-files-found: error + retention-days: 3 + - uses: actions/upload-artifact@v4 + if: needs.pick.outputs.dry_run == 'true' + with: + name: ephemeral.pub + path: dist/ephemeral.pub + retention-days: 3 + + publish: + needs: [pick, build, sign] + runs-on: ubuntu-latest + timeout-minutes: 15 + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - uses: actions/download-artifact@v4 + with: + path: dist + merge-multiple: true + - name: The signature, checked as launchers check it + env: + EPHEMERAL: ${{ needs.pick.outputs.dry_run == 'true' && 'yes' || '' }} + run: | + key=(); [[ -n "$EPHEMERAL" ]] && key=(--key "$(cat dist/ephemeral.pub)") + cargo run --locked --quiet -p horizon-release-sign -- verify --tag nightly --publishing "${key[@]}" dist + - name: The smoke test drew a world + # No release-blocker check: a nightly is how blockers get tested. + run: python3 tools/release_train.py gate --kind game --smoke dist/smoke-test.json + - name: Publish as the `nightly` pre-release + if: needs.pick.outputs.dry_run != 'true' + env: + GH_TOKEN: ${{ github.token }} + SHA: ${{ needs.pick.outputs.sha }} + DATE: ${{ needs.pick.outputs.date }} + run: | + set -euo pipefail + python3 tools/ci/nightly.py rotate + signature=(); [[ -f dist/SHA256SUMS.sig ]] && signature=(dist/SHA256SUMS.sig) + # A pre-release, never GitHub's latest: launchers on the release channel never see it. + gh release create nightly --prerelease --latest=false --target "$SHA" \ + --title "Nightly $DATE · ${SHA:0:7}" --notes-file dist/nightly-notes.md \ + "dist/horizon-linux-x86_64.tar.gz#Nightly game files: Linux (horizon-linux-x86_64.tar.gz)" \ + "dist/horizon-windows-x64.zip#Nightly game files: Windows (horizon-windows-x64.zip)" \ + "dist/horizon-macos-arm64.zip#Nightly game files: macOS (horizon-macos-arm64.zip)" \ + "dist/horizon-server-linux-x86_64.tar.gz#Nightly dedicated server for Linux (horizon-server-linux-x86_64.tar.gz)" \ + dist/SHA256SUMS "${signature[@]}" dist/smoke-test.json + python3 tools/ci/nightly.py prune --days 7 + - name: Dry run, the nightly that would be published + if: needs.pick.outputs.dry_run == 'true' + run: | + echo "Would publish nightly at ${{ needs.pick.outputs.sha }} (${{ needs.pick.outputs.source }})" + ls -l dist diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d879f0d61..c1182d493 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -79,252 +79,14 @@ jobs: # A dry run builds whatever the decision, to test the builds. if [[ "${{ steps.mode.outputs.dry_run }}" == true ]]; then echo "release=true" >> "$GITHUB_OUTPUT"; fi - exporters: + build: needs: decide if: needs.decide.outputs.release == 'true' - # This runner holds the maintainer's own pinned Minecraft jars. Only our classes leave it. - runs-on: ${{ vars.MAC_RUNNER || 'ludovics-mac-mini' }} - # Three full preparations (two isolated, one batched) besides the compile. - timeout-minutes: 60 - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ needs.decide.outputs.head }} - persist-credentials: false - clean: true - - uses: dtolnay/rust-toolchain@stable - - run: bash tools/ci/runner-env.sh - - run: bash tools/ci/vanilla-data.sh - - name: Compile and validate original exporters against the pinned jars - shell: bash - run: | - set -euo pipefail - # target/ is gone after the clean checkout, and vanilla-data.sh builds the preparer only when it - # prepares afresh. - cargo build --release --locked -p horizon-prepare - # Compiled here, never taken from the runner's shared preparations: pull requests' parity jobs - # write those (vanilla-data.sh links .local/exporters to them). - rm -rf .local/exporters - bundle=$(target/release/horizon-prepare compile-exporters --root "$PWD" | tail -1) - mkdir -p exporters - cp -R "$bundle/server" "$bundle/client" "$bundle/manifest.json" exporters/ - # Only our classes and their manifest leave this runner. - stray=$(find exporters -type f ! -path exporters/manifest.json \ - ! \( -name '*.class' \( -path 'exporters/server/dev/horizonlab/parity/*' -o -path 'exporters/client/dev/horizonlab/parity/*' \) \)) - [ -z "$stray" ] || { echo "::error::not one of our classes: $stray"; exit 1; } - python3 tools/check_prepare_exporters.py --binary target/release/horizon-prepare - - uses: actions/upload-artifact@v4 - with: - name: original-exporters - path: exporters/ - if-no-files-found: error - retention-days: 3 - - build: - needs: [decide, exporters] - if: needs.decide.outputs.release == 'true' - name: build ${{ matrix.name }} - strategy: - fail-fast: false - matrix: - include: - - name: linux - os: ubuntu-22.04 - dir: horizon-linux-x86_64 - asset: horizon-linux-x86_64.tar.gz - # The server build too: packaging/server/install.sh installs it on Linux. - server_dir: horizon-server-linux-x86_64 - server_asset: horizon-server-linux-x86_64.tar.gz - - name: windows - os: windows-latest - dir: horizon-windows-x64 - asset: horizon-windows-x64.zip - exe: .exe - # The C runtime linked in, so the game runs without the Visual C++ redistributable. - rustflags: -C target-feature=+crt-static - - name: macos - mac: true - dir: horizon-macos-arm64 - asset: horizon-macos-arm64.zip - runs-on: ${{ matrix.mac && (vars.MAC_RUNNER || 'ludovics-mac-mini') || matrix.os }} - # Notarizing the zip can take a few minutes. - timeout-minutes: ${{ matrix.mac && 60 || 40 }} - env: - RUSTFLAGS: ${{ matrix.rustflags }} - # The release's version, built in (horizon_core::release): --version, user agents, crash reports and - # telemetry say it. No version-bump commits. - HORIZON_VERSION: ${{ needs.decide.outputs.version }} - defaults: - run: - shell: bash - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ needs.decide.outputs.head }} - persist-credentials: false - # Always from a clean checkout, the Mac mini's runner too: its work folder is shared with pull requests' - # parity jobs, and nothing they leave (target/, an untracked .cargo/config.toml, a build script's output) - # may end up in a release. target/ is rebuilt from scratch; .local/ is relinked by vanilla-data.sh, which - # keeps its preparations outside the checkout. - clean: true - - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - if: runner.environment == 'github-hosted' - with: - shared-key: release-${{ matrix.name }} - - name: ALSA and udev headers - if: runner.os == 'Linux' - run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libasound2-dev libudev-dev - - name: Build the client, horizon-ctl, horizon-prepare and horizon-server - # `horizon-client/mods`: every released game runs code mods (the feature is off in dev builds). - run: cargo build --release --locked --features horizon-client/mods -p horizon-client --bin horizon-client --bin horizon-ctl -p horizon-prepare --bin horizon-prepare -p horizon-server --bin horizon-server - - name: Every program the release folder takes was built - run: | - for binary in horizon-client horizon-ctl horizon-prepare horizon-server; do - test -f "target/release/$binary${{ matrix.exe }}" || { echo "::error::target/release/$binary${{ matrix.exe }} is missing"; exit 1; } - done - - name: The signing keychain, unlocked - if: runner.os == 'macOS' && vars.MACOS_SIGN_IDENTITY != '' - env: - MACOS_SIGN_IDENTITY: ${{ vars.MACOS_SIGN_IDENTITY }} - run: packaging/macos/keychain.sh unlock - - name: Signed with Developer ID and the hardened runtime - # Before the checks below, so they run the programs as players will. - if: runner.os == 'macOS' && vars.MACOS_SIGN_IDENTITY != '' - env: - MACOS_SIGN_IDENTITY: ${{ vars.MACOS_SIGN_IDENTITY }} - run: | - for binary in horizon-client horizon-ctl horizon-prepare horizon-server; do - codesign --force --options runtime --timestamp --keychain "$MACOS_SIGN_KEYCHAIN" \ - --identifier "dev.horizon.${binary#horizon-}" --sign "$MACOS_SIGN_IDENTITY" "target/release/$binary" - codesign --verify --strict --verbose=2 "target/release/$binary" - done - - name: Only system libraries - # Windows: no non-system DLL (a "DLL not found" dialog on some players' machines). Linux: the standard - # loader and libraries every desktop distribution has. macOS: only the system's own libraries. - run: | - for binary in horizon-client horizon-ctl horizon-prepare horizon-server; do - file="target/release/$binary${{ matrix.exe }}" - if [[ "$RUNNER_OS" == macOS ]]; then - others=$(otool -L "$file" | tail -n +2 | awk '{print $1}' | grep -v -E '^(/usr/lib/|/System/Library/)' || true) - [[ -z "$others" ]] || { echo "::error::$binary links $others"; exit 1; } - else - ${{ runner.os == 'Windows' && 'python' || 'python3' }} tools/check_imports.py "$file" - fi - done - - name: Every program starts - run: | - set -euo pipefail - bin=target/release - "$bin/horizon-client${{ matrix.exe }}" --help | grep -q -- '--resources' - "$bin/horizon-ctl${{ matrix.exe }}" --help > /dev/null - "$bin/horizon-prepare${{ matrix.exe }}" --help | grep -q -- '--minecraft-dir' - # The version is the release's. - for binary in horizon-prepare horizon-server; do - out=$("$bin/$binary${{ matrix.exe }}" --version | tr -d '\r') - echo "$out" - [[ "$out" == "$binary $HORIZON_VERSION" ]] || { echo "::error::expected $binary $HORIZON_VERSION"; exit 1; } - done - - name: Tools from the runner - if: runner.environment == 'self-hosted' - run: bash tools/ci/runner-env.sh - - name: Resources prepared from the runner's own Minecraft - if: runner.environment == 'self-hosted' - run: bash tools/ci/vanilla-data.sh - - name: The game runs (offscreen, a new world, 1500 frames) - if: runner.environment == 'self-hosted' - run: | - set -euo pipefail - # From a scratch folder: the game keeps its saves and options in the folder it starts in. - home="$RUNNER_TEMP/horizon-smoke" - rm -rf "$home" && mkdir -p "$home" - version=$(sed -n 's/.*"version": *"\([^"]*\)".*/\1/p' research-lock.json | head -1) - client="$PWD/target/release/horizon-client" - resources="$PWD/.local/horizon-client/$version" - (cd "$home" && HORIZON_HOME="$home" HORIZON_NO_AUDIO=1 "$client" --resources "$resources" --offscreen \ - --world smoke --seed 1 --render-distance 4 --world-frames 1500 --timeout-seconds 180 \ - --smoke-report "$home/smoke.json" > "$home/client.log" 2>&1) || { tail -40 "$home/client.log"; exit 1; } - python3 - "$home/smoke.json" <<'EOF' - import json, sys - report = json.load(open(sys.argv[1])) - print(json.dumps(report)) - if report.get("error") is not None or report.get("frames", 0) < 1500 or not report.get("chunks") \ - or not report.get("meshed_sections") or not report.get("player"): - sys.exit("the smoke run did not draw a world") - EOF - # Published with the release; the publish job checks it again before it publishes anything. - cp "$home/smoke.json" "$RUNNER_TEMP/smoke-test.json" - - uses: actions/upload-artifact@v4 - if: runner.environment == 'self-hosted' - with: - name: smoke-test.json - path: ${{ runner.temp }}/smoke-test.json - if-no-files-found: error - retention-days: 3 - - uses: actions/download-artifact@v4 - with: - name: original-exporters - path: exporters - - name: Package - run: | - set -euo pipefail - cargo run --locked -p xtask -- package "target/release/horizon-client${{ matrix.exe }}" "dist/${{ matrix.dir }}" - cd dist - rm -f "${{ matrix.asset }}" - case "${{ matrix.asset }}" in - *.tar.gz) tar czf "${{ matrix.asset }}" "${{ matrix.dir }}" ;; - *) if [[ "$RUNNER_OS" == Windows ]]; then 7z a -tzip "${{ matrix.asset }}" "${{ matrix.dir }}" > /dev/null - else - # Without resource forks and extended attributes: plain ditto adds an - # AppleDouble `._` file beside every file that has any. - ditto -c -k --norsrc --noextattr --noqtn --keepParent "${{ matrix.dir }}" "${{ matrix.asset }}" - if unzip -Z1 "${{ matrix.asset }}" | grep -E '(^|/)(\._|__MACOSX/)'; then - echo "::error::macOS metadata files in ${{ matrix.asset }}"; exit 1 - fi - fi ;; - esac - ls -l "${{ matrix.asset }}" - - name: Notarized - # A zip of programs can't be stapled: Gatekeeper asks Apple the first time each one runs. - if: runner.os == 'macOS' && vars.MACOS_SIGN_IDENTITY != '' - run: | - for binary in horizon-client horizon-ctl horizon-prepare horizon-server; do - codesign --verify --strict "dist/${{ matrix.dir }}/$binary" - done - packaging/macos/notarize.sh "dist/${{ matrix.asset }}" - - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.asset }} - path: dist/${{ matrix.asset }} - if-no-files-found: error - retention-days: 3 - - name: The server build (the game without sound or controllers, as horizon-engine) - if: matrix.server_asset - run: | - set -euo pipefail - # After the client is packaged: target/release/horizon-client is rebuilt without the audio and - # controllers features, so it needs neither libasound nor libudev (minimal server images lack them), - # and with code mods like the client. - cargo build --release --locked -p horizon-client --no-default-features --features mods --bin horizon-client - cargo run --locked -p xtask -- package-server target/release/horizon-client "dist/${{ matrix.server_dir }}" - folder="dist/${{ matrix.server_dir }}" - python3 tools/check_imports.py --server "$folder/horizon-engine" "$folder/horizon-server" "$folder/horizon-prepare" - "$folder/horizon-engine" --help | grep -q -- '--resources' - [[ "$("$folder/horizon-server" --version)" == "horizon-server $HORIZON_VERSION" ]] - cd dist - rm -f "${{ matrix.server_asset }}" - tar czf "${{ matrix.server_asset }}" "${{ matrix.server_dir }}" - ls -l "${{ matrix.server_asset }}" - - uses: actions/upload-artifact@v4 - if: matrix.server_asset - with: - name: ${{ matrix.server_asset }} - path: dist/${{ matrix.server_asset }} - if-no-files-found: error - retention-days: 3 - - name: The signing keychain, locked again - if: always() && runner.os == 'macOS' && vars.MACOS_SIGN_IDENTITY != '' - run: packaging/macos/keychain.sh lock + # Every platform's archive, and macOS's smoke test (game-build.yml). + uses: ./.github/workflows/game-build.yml + with: + ref: ${{ needs.decide.outputs.head }} + version: ${{ needs.decide.outputs.version }} sign: needs: [decide, build] diff --git a/docs/release-flow.md b/docs/release-flow.md index be0ccbee8..a8d559c91 100644 --- a/docs/release-flow.md +++ b/docs/release-flow.md @@ -262,8 +262,10 @@ silent (no ping and Discord's @silent flag). Launcher releases post without a pi ### One channel -Since 2026-10-23 there is one channel. Every game release is published as the release, never a pre-release, and -marked GitHub's *latest*: the launcher, `horizon-server update` and `install.sh` take it at once. Because nothing +Since 2026-10-23 there is one release channel, and it is every launcher's default. Since 2026-10-27 (Ludovic's +decision, revising 2026-10-23's) players may also turn on [Nightly](#nightly-channel), an opt-in pre-release built +from reviewed pull requests; nothing about releases changes for anyone who doesn't. Every game release is published +as the release, never a pre-release, and marked GitHub's *latest*: the launcher, `horizon-server update` and `install.sh` take it at once. Because nothing promotes it later, the checks that used to gate a promotion run in the release itself, and the publish job (`tools/release_train.py gate`) publishes nothing unless both pass: @@ -407,6 +409,37 @@ With several game releases a day, the newest launcher release soon falls out of launcher and the website read: both then look the newest launcher tags up one by one (`git/matching-refs/tags/launcher@`, then `launcher-v` if there is none, then `releases/tags/`). +## Nightly channel + +`.github/workflows/nightly-build.yml` publishes an opt-in build once a night (20:17 UTC), for players who want +reviewed fixes before they are released (#2681). It builds the newest `union/-` branch on origin (main +plus the pull requests the contribution gate proved together in one wave) when that union is newer than main's head +and holds something main lacks, otherwise main (`tools/ci/nightly.py pick`). A night with nothing new publishes +nothing. Only proven unions are pushed to origin, so nothing unreviewed ships. + +- **Jobs.** `pick` chooses the commit and writes the notes (the open pull requests it holds beyond main). `build` is + `game-build.yml`, the same builds and smoke test as a release, with the version `nightly-` and + `HORIZON_NIGHTLY=" "` built in, macOS signed ad hoc. `sign` signs SHA256SUMS for the channel + (the message says `horizon release nightly`, so a nightly's signature never passes for a release's). `publish` + checks the signature and the smoke test (not `release-blocker`: a nightly is how blockers get tested), renames the + previous `nightly` pre-release to `nightly-`, publishes the new one as the `nightly` pre-release (never + GitHub's latest), and deletes the `nightly-` pre-releases and tags older than 7 days, nothing else. +- **The signing key never meets the union's code.** Every workflow file and script runs from main's copy (a schedule + runs the default branch; `uses: ./…` takes the caller's commit), never the union's `.github/`. `build` compiles the + union with a read-only token that isn't kept in the checkout and no secrets; the runner's Developer ID keychain + stays locked. `sign` is the only job with the key, and checks out only main's `tools/ci/sign_release.sh`, which + hashes the archives with the runner's `sha256sum` and signs with its OpenSSL: it never runs what `build` made. + `publish` runs main's `horizon-release-sign`, never the archives. +- **Players.** Releases stay the default and the only channel any launcher follows unless its player turns Nightly + on. `release_train.py`, `horizon-server update`, `install.sh` and the launcher's release list skip the tags: none + of them is `vX.Y.Z`. + +```sh +gh workflow run "nightly build" # now; skips when the pick is the commit already published +gh workflow run "nightly build" -f force=true # build and publish anyway +gh workflow run "nightly build" -f dry_run=true # build and sign with a throwaway key, publish nothing +``` + ## Nightly audit `.github/workflows/nightly.yml` runs every harness from scratch (`tools/parity.py --all`) on main at 03:00 Paris diff --git a/tests/test_nightly.py b/tests/test_nightly.py new file mode 100644 index 000000000..2bbf8fc98 --- /dev/null +++ b/tests/test_nightly.py @@ -0,0 +1,49 @@ +import datetime as dt +import unittest + +from tools.ci import nightly + +T = dt.datetime(2026, 10, 28, 12, 0, tzinfo=dt.timezone.utc) + + +def ref(name, sha, hours): + return nightly.Ref(name, sha, T + dt.timedelta(hours=hours)) + + +class NightlyTests(unittest.TestCase): + def test_the_newest_union_newer_than_main_is_built(self): + main = ref("main", "m", 0) + unions = [ref("union/a", "a", 1), ref("union/b", "b", 3), ref("union/c", "c", -2)] + self.assertEqual(nightly.choose(main, unions, contains=lambda a, b: False).name, "union/b") + + def test_main_when_no_union_is_newer(self): + main = ref("main", "m", 5) + unions = [ref("union/a", "a", 1), ref("union/b", "b", 3)] + self.assertEqual(nightly.choose(main, unions, contains=lambda a, b: False).name, "main") + self.assertEqual(nightly.choose(main, [], contains=lambda a, b: False).name, "main") + + def test_a_union_main_already_holds_is_skipped(self): + main = ref("main", "m", 0) + unions = [ref("union/landed", "l", 2), ref("union/open", "o", 1)] + landed = lambda a, b: a == "l" # noqa: E731 + self.assertEqual(nightly.choose(main, unions, contains=landed).name, "union/open") + + def test_only_old_dated_nightlies_are_pruned(self): + tags = [{"tagName": "nightly", "isPrerelease": True}, + {"tagName": "nightly-2026-10-20", "isPrerelease": True}, + {"tagName": "nightly-2026-10-21", "isPrerelease": True}, + {"tagName": "nightly-2026-10-19", "isPrerelease": False}, + {"tagName": "v0.2.80", "isPrerelease": False}, + {"tagName": "nightly-2026-10-15-extra", "isPrerelease": True}] + self.assertEqual(nightly.stale(tags, dt.date(2026, 10, 28), 7), ["nightly-2026-10-20"]) + + def test_notes_list_what_is_not_on_main(self): + text = nightly.notes("2026-10-28", ref("union/a", "0c0206714abc", 1), + [{"number": 2476, "title": "Fix pistons", "headRefOid": "x"}]) + self.assertIn("Nightly 2026-10-28 · 0c02067", text) + self.assertIn("- Fix pistons (#2476)", text) + self.assertIn("Everything in it is on main.", nightly.notes("2026-10-28", ref("main", "m" * 40, 0), [])) + + +if __name__ == "__main__": + unittest.main() diff --git a/tools/ci/nightly.py b/tools/ci/nightly.py new file mode 100644 index 000000000..57af588c1 --- /dev/null +++ b/tools/ci/nightly.py @@ -0,0 +1,155 @@ +#!/usr/bin/env python3 +"""The opt-in Nightly channel (.github/workflows/nightly-build.yml, docs/release-flow.md "Nightly"). + + nightly.py pick [--force] which commit tonight's nightly builds: GitHub outputs and nightly-notes.md + nightly.py rotate renames the current `nightly` pre-release to nightly-, frees the tag + nightly.py prune [--days 7] deletes the nightly- pre-releases and tags older than that, nothing else + +A nightly builds the newest union branch on origin (`union/-`: main plus pull requests the contribution +gate proved together), or main when no union is newer than main's head. It is published as the `nightly` +pre-release; the previous one stays a week as nightly-. Runs from main's checkout with `gh`; it reads the +branch it picks with git and never runs anything from it. +""" +from __future__ import annotations + +import argparse +import datetime as dt +import json +import os +import re +import subprocess +import sys +from dataclasses import dataclass + +DATED = re.compile(r"^nightly-(\d{4}-\d{2}-\d{2})$") +TITLE_DATE = re.compile(r"Nightly (\d{4}-\d{2}-\d{2})") + + +@dataclass +class Ref: + name: str + sha: str + date: dt.datetime # committer date + + +def git(*args: str) -> str: + return subprocess.run(["git", *args], check=True, capture_output=True, text=True).stdout.strip() + + +def gh(*args: str, check: bool = True) -> str: + out = subprocess.run(["gh", *args], capture_output=True, text=True) + if check and out.returncode != 0: + sys.exit(f"gh {' '.join(args)}: {out.stderr.strip()}") + return out.stdout.strip() if out.returncode == 0 else "" + + +def is_ancestor(a: str, b: str) -> bool: + return subprocess.run(["git", "merge-base", "--is-ancestor", a, b]).returncode == 0 + + +def choose(main: Ref, unions: list[Ref], contains=is_ancestor) -> Ref: + """The newest union whose head is newer than main's and holds something main lacks; else main.""" + for u in sorted(unions, key=lambda u: u.date, reverse=True): + if u.date <= main.date: + break + if not contains(u.sha, main.sha): + return u + return main + + +def refs(pattern: str) -> list[Ref]: + out = git("for-each-ref", "--format=%(refname:short) %(objectname) %(committerdate:iso-strict)", pattern) + return [Ref(n.removeprefix("origin/"), s, dt.datetime.fromisoformat(d)) + for n, s, d in (line.split(" ", 2) for line in out.splitlines())] + + +def output(**values: str) -> None: + with open(os.environ.get("GITHUB_OUTPUT", "/dev/stdout"), "a") as f: + for k, v in values.items(): + f.write(f"{k}={v}\n") + + +def notes(today: str, chosen: Ref, held: list[dict]) -> str: + lines = [f"Nightly {today} · {chosen.sha[:7]}: built from `{chosen.name}` ({chosen.sha}).", "", + "**Opt-in, not a release.** Fixes the maintainers reviewed but haven't released yet: it may break. " + "Turn it on in the launcher's settings; your release install and your worlds stay as they are. " + "Report bugs with the version the game shows (\"Nightly · \").", ""] + if held: + lines += [f"### Not on main yet ({len(held)})", ""] + lines += [f"- {p['title']} (#{p['number']})" for p in held] + else: + lines += ["Everything in it is on main."] + return "\n".join(lines) + "\n" + + +def pick(force: bool) -> None: + git("fetch", "--quiet", "origin", "+refs/heads/main:refs/remotes/origin/main", + "+refs/heads/union/*:refs/remotes/origin/union/*") + main = refs("refs/remotes/origin/main")[0] + chosen = choose(main, refs("refs/remotes/origin/union/")) + today = dt.datetime.now(dt.timezone.utc).date().isoformat() + previous = git("ls-remote", "--tags", "origin", "refs/tags/nightly").split("\t")[0] or None + build = force or previous != chosen.sha + # The open pull requests this build holds beyond main: their heads are in it and not in main. + prs = json.loads(gh("pr", "list", "--state", "open", "--limit", "400", "--json", "number,title,headRefOid")) + held = [] + for pr in prs: + oid = pr["headRefOid"] + if subprocess.run(["git", "cat-file", "-e", oid], capture_output=True).returncode != 0: + continue # a fork's head that no fetched branch holds + if is_ancestor(oid, chosen.sha) and not is_ancestor(oid, main.sha): + held.append(pr) + held.sort(key=lambda p: p["number"]) + with open("nightly-notes.md", "w") as f: + f.write(notes(today, chosen, held)) + output(build=str(build).lower(), sha=chosen.sha, short=chosen.sha[:7], source=chosen.name, date=today, + version=f"nightly-{today}", nightly=f"{today} {chosen.sha[:7]}") + print(f"{'build' if build else 'skip (unchanged since the last nightly)'}: {chosen.name} {chosen.sha}, " + f"{len(held)} open pull requests beyond main") + + +def rotate() -> None: + """The current `nightly` becomes nightly-, so tonight's can take the tag.""" + current = gh("release", "view", "nightly", "--json", "name", check=False) + if not current: + return + m = TITLE_DATE.search(json.loads(current)["name"]) + dated = f"nightly-{m.group(1)}" if m else f"nightly-{dt.date.today() - dt.timedelta(days=1)}" + if gh("release", "view", dated, "--json", "tagName", check=False): + gh("release", "delete", dated, "--cleanup-tag", "--yes") # a second nightly the same day replaces the first + gh("release", "edit", "nightly", "--tag", dated) + gh("api", "-X", "DELETE", f"repos/{os.environ['GITHUB_REPOSITORY']}/git/refs/tags/nightly", check=False) + print(f"nightly -> {dated}") + + +def stale(tags: list[dict], today: dt.date, days: int) -> list[str]: + """The dated nightly pre-releases older than `days`: never a release, never `nightly` itself.""" + cutoff = today - dt.timedelta(days=days) + return [r["tagName"] for r in tags if r["isPrerelease"] and (m := DATED.match(r["tagName"])) + and dt.date.fromisoformat(m.group(1)) < cutoff] + + +def prune(days: int) -> None: + tags = json.loads(gh("release", "list", "--limit", "200", "--json", "tagName,isPrerelease")) + for tag in stale(tags, dt.datetime.now(dt.timezone.utc).date(), days): + gh("release", "delete", tag, "--cleanup-tag", "--yes") + print(f"deleted {tag}") + + +def main() -> None: + ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) + sub = ap.add_subparsers(dest="cmd", required=True) + sub.add_parser("pick").add_argument("--force", action="store_true") + sub.add_parser("rotate") + sub.add_parser("prune").add_argument("--days", type=int, default=7) + args = ap.parse_args() + if args.cmd == "pick": + pick(args.force) + elif args.cmd == "rotate": + rotate() + else: + prune(args.days) + + +if __name__ == "__main__": + main()