From c2f94f0f7f1140653263abd52362f6f06ba81e72 Mon Sep 17 00:00:00 2001 From: Allister MacLeod Date: Fri, 12 Jun 2026 10:13:05 -0400 Subject: [PATCH] Add RC conveniences to release-unity.yml Fold the useful pieces of the retired combined workflow into the real Unity release, keeping CLI and Unity decoupled and the npm trusted publisher intact: - nugetVersion input: jq-writes versions-default.json at build time so the bundled CLI version no longer needs a hand-edit of the deep file. Blank keeps the SDK's current dependency, i.e. reuse the previous CLI artifact when the CLI has not changed. - rcNumber 0 (the default) auto-derives the next RC from existing tags for the rc release type; an explicit rcNumber wins. - Fail-fast changelog guard for rc/production: the changelog top entry must match the version line being cut, checked before any build. Non-rc modes (nightly/exp/production) are unchanged except the shared changelog guard, which runs only for rc and production. Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/release-unity.yml | 54 ++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-unity.yml b/.github/workflows/release-unity.yml index c2d8c8213f..a2b5dbc5ab 100644 --- a/.github/workflows/release-unity.yml +++ b/.github/workflows/release-unity.yml @@ -24,9 +24,14 @@ on: default: 0 rcNumber: type: number - description: Rc version number, if required, 0.0.0-PREVIEW.RCX + description: "Rc version number (0 = auto: next RC after the latest tag)" required: false default: 0 + nugetVersion: + type: string + description: "CLI nuget version to bundle. Blank = keep the SDK's current dependency." + required: false + default: "" releaseType: type: choice description: What type of release is this? @@ -76,9 +81,39 @@ jobs: echo releaseType=${{ inputs.releaseType }} - uses: actions/checkout@v4 - with: + with: ref: ${{ github.event.inputs.commit }} + # For an RC with rcNumber 0, derive the next RC from existing tags (read + # from the remote, so a shallow clone is fine). Lets you cut RC2..N without + # tracking the number. An explicit rcNumber > 0 wins. ~Claude + - name: Resolve RC number + id: rc + if: ${{ inputs.releaseType == 'rc' }} + run: | + set -euo pipefail + rc="${{ inputs.rcNumber }}" + if [ "$rc" = "0" ] || [ -z "$rc" ]; then + max=$(git ls-remote --tags origin "unity-sdk-${{ inputs.major }}.${{ inputs.minor }}.${{ inputs.patch }}-PREVIEW.RC*" \ + | sed -nE 's#.*-PREVIEW\.RC([0-9]+)$#\1#p' | sort -n | tail -1) + if [ -z "$max" ]; then rc=1; else rc=$((max + 1)); fi + fi + echo "NUMBER=$rc" >> "$GITHUB_OUTPUT" + echo "Resolved RC number: $rc" + + # Fail fast, before any build, if the changelog's top entry does not match + # the version line being cut. ~Claude + - name: Guard changelog freshness + if: ${{ inputs.releaseType == 'rc' || inputs.releaseType == 'production' }} + run: | + want="${{ inputs.major }}.${{ inputs.minor }}.${{ inputs.patch }}" + top=$(grep -m1 -oP '^##\s*\[\K[0-9]+\.[0-9]+\.[0-9]+' client/Packages/com.beamable/CHANGELOG.md || true) + if [ "$top" != "$want" ]; then + echo "::error file=client/Packages/com.beamable/CHANGELOG.md::Changelog top entry '$top' does not match $want. Update the changelog before releasing." + exit 1 + fi + echo "Changelog OK: $top" + - name: Log in to the Container registry uses: docker/login-action@v3 with: @@ -136,8 +171,8 @@ jobs: run: beam version construct 0 0 0 --nightly > version.txt - name: Get Version Number (RC) - if: ${{ inputs.releaseType == 'rc' }} - run: beam version construct ${{ inputs.major }} ${{ inputs.minor }} ${{ inputs.patch }} --rc ${{ inputs.rcNumber }} > version.txt + if: ${{ inputs.releaseType == 'rc' }} + run: beam version construct ${{ inputs.major }} ${{ inputs.minor }} ${{ inputs.patch }} --rc ${{ steps.rc.outputs.NUMBER }} > version.txt - name: Get Version Number (Exp) if: ${{ inputs.releaseType == 'exp' }} @@ -194,6 +229,17 @@ jobs: VERSION: ${{ steps.version.outputs.VERSION }} ENVIRONMENT: ${{steps.version.outputs.BUILD_ENV}} + # Point the SDK at a specific CLI nuget version without hand-editing the + # committed file. Blank input keeps the current dependency (reuse the + # previous CLI artifact when the CLI has not changed). ~Claude + - name: Override bundled CLI nuget version + if: ${{ inputs.nugetVersion != '' }} + run: | + jq --arg v "${{ inputs.nugetVersion }}" '.nugetPackageVersion = $v' \ + client/Packages/com.beamable/Runtime/Environment/Resources/versions-default.json > tmp.json \ + && mv tmp.json client/Packages/com.beamable/Runtime/Environment/Resources/versions-default.json + cat client/Packages/com.beamable/Runtime/Environment/Resources/versions-default.json + - name: Apply Nuget Version to Unity SDK run: | beam unity download-all-nuget-packages ./client --logs v