| 1 | name: Release candidate |
| 2 | run-name: ${{ inputs.nightly && 'Nightly release candidate' || 'Release candidate' }} |
| 3 | |
| 4 | # Safe pre-publication artifact proof. This workflow never creates a tag or |
| 5 | # release and never writes to a registry, container repository, tap, or deploy. |
| 6 | on: |
| 7 | workflow_dispatch: |
| 8 | inputs: |
| 9 | expected_sha: |
| 10 | description: Exact 40-character commit selected by --ref (must match the dispatch SHA) |
| 11 | required: true |
| 12 | type: string |
| 13 | nightly: |
| 14 | description: Nightly build of main (nightly-candidate.yml). Allows an undated CHANGELOG and never signs the manifest |
| 15 | required: false |
| 16 | default: false |
| 17 | type: boolean |
| 18 | macos_runner: |
| 19 | description: macOS shipping-build runner (default follows the CW_SELF_HOSTED_MAC repository variable; self-hosted is the codewhale-mac runner) |
| 20 | type: choice |
| 21 | default: default |
| 22 | options: |
| 23 | - default |
| 24 | - self-hosted |
| 25 | - hosted |
| 26 | |
| 27 | permissions: |
| 28 | contents: read |
| 29 | |
| 30 | concurrency: |
| 31 | group: release-candidate-${{ github.sha }} |
| 32 | cancel-in-progress: false |
| 33 | |
| 34 | jobs: |
| 35 | resolve: |
| 36 | name: Resolve exact candidate source |
| 37 | timeout-minutes: 10 |
| 38 | runs-on: ubuntu-24.04 |
| 39 | outputs: |
| 40 | sha: ${{ steps.source.outputs.sha }} |
| 41 | version: ${{ steps.source.outputs.version }} |
| 42 | steps: |
| 43 | - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 |
| 44 | with: |
| 45 | fetch-depth: 0 |
| 46 | - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 |
| 47 | with: |
| 48 | node-version: 22 |
| 49 | package-manager-cache: false |
| 50 | - uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 # stable 2026-07-18 |
| 51 | with: |
| 52 | toolchain: 1.100.0 |
| 53 | - name: Match dispatch to the requested commit |
| 54 | id: source |
| 55 | shell: bash |
| 56 | env: |
| 57 | EXPECTED_SHA: ${{ inputs.expected_sha }} |
| 58 | run: | |
| 59 | set -euo pipefail |
| 60 | if [[ "${#EXPECTED_SHA}" -ne 40 || "${EXPECTED_SHA}" =~ [^0-9a-fA-F] ]]; then |
| 61 | echo "::error::expected_sha must be a full 40-character commit SHA." >&2 |
| 62 | exit 1 |
| 63 | fi |
| 64 | actual="$(git rev-parse HEAD)" |
| 65 | expected_normalized="$(printf '%s' "${EXPECTED_SHA}" | tr '[:upper:]' '[:lower:]')" |
| 66 | if [[ "${actual}" != "${expected_normalized}" ]]; then |
| 67 | echo "::error::Dispatch resolved to ${actual}, not requested ${EXPECTED_SHA}." >&2 |
| 68 | exit 1 |
| 69 | fi |
| 70 | |
| 71 | workspace_version="$(grep -E '^version = "' Cargo.toml | head -n1 | sed -E 's/^version = "([^"]+)".*/\1/')" |
| 72 | npm_version="$(node -p "require('./npm/codewhale/package.json').version")" |
| 73 | binary_version="$(node -p "require('./npm/codewhale/package.json').codewhaleBinaryVersion")" |
| 74 | if [[ "${workspace_version}" != "${npm_version}" ]]; then |
| 75 | echo "::error::Candidate version drift: workspace=${workspace_version}, npm=${npm_version}, binary=${binary_version}." >&2 |
| 76 | exit 1 |
| 77 | fi |
| 78 | if [[ "${workspace_version}" != "${binary_version}" ]]; then |
| 79 | echo "::error::Candidate version drift: workspace=${workspace_version}, npm=${npm_version}, binary=${binary_version}." >&2 |
| 80 | exit 1 |
| 81 | fi |
| 82 | |
| 83 | echo "sha=${actual}" >> "${GITHUB_OUTPUT}" |
| 84 | echo "version=${workspace_version}" >> "${GITHUB_OUTPUT}" |
| 85 | - name: Check the first-party catalog snapshot is current |
| 86 | run: ./scripts/refresh-first-party-marketplace.sh --check |
| 87 | - name: Check version and OHOS release contracts |
| 88 | # --require-dated-release, as auto-tag.yml and release.yml run it: |
| 89 | # release.yml only accepts an RC receipt for the exact tag SHA, so an |
| 90 | # RC on an undated "Unreleased candidate" changelog could never |
| 91 | # authorize a release. Fail here, before the long parity and artifact |
| 92 | # builds, instead of at tag time. A nightly build of undated main |
| 93 | # skips the flag; release.yml reruns it on the tag SHA, so that |
| 94 | # receipt still cannot authorize an undated release. |
| 95 | env: |
| 96 | NIGHTLY: ${{ inputs.nightly }} |
| 97 | run: | |
| 98 | if [[ "${NIGHTLY}" == "true" ]]; then |
| 99 | ./scripts/release/check-versions.sh |
| 100 | else |
| 101 | ./scripts/release/check-versions.sh --require-dated-release |
| 102 | fi |
| 103 | ./scripts/release/check-ohos-deps.sh |
| 104 | - name: Reconfirm clean source snapshot |
| 105 | run: git diff --exit-code |
| 106 | |
| 107 | web: |
| 108 | name: Verify exact candidate web surface |
| 109 | timeout-minutes: 15 |
| 110 | needs: resolve |
| 111 | if: ${{ !cancelled() && needs.resolve.result == 'success' }} |
| 112 | runs-on: ubuntu-24.04 |
| 113 | defaults: |
| 114 | run: |
| 115 | working-directory: web |
| 116 | steps: |
| 117 | # resolve already proved expected_sha equals GITHUB_SHA. Do not |
| 118 | # interpolate that SHA into checkout or the npm cache key. |
| 119 | - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 |
| 120 | with: |
| 121 | # `check:facts` derives each model's `addedAt` from the commit date |
| 122 | # on which its id first appeared in the model declaration paths |
| 123 | # (web/scripts/facts-lib.mjs). A shallow checkout collapses every |
| 124 | # date to the tip commit and the committed facts always read as |
| 125 | # stale; web.yml and ci.yml pin depth 0 for the same reason. |
| 126 | fetch-depth: 0 |
| 127 | - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 |
| 128 | with: |
| 129 | node-version: 22 |
| 130 | cache: npm |
| 131 | cache-dependency-path: web/package-lock.json |
| 132 | - name: Install web dependencies |
| 133 | run: npm ci |
| 134 | - name: Run web tests |
| 135 | run: npm test |
| 136 | - name: Check exact candidate web surface |
| 137 | env: |
| 138 | GITHUB_TOKEN: ${{ github.token }} |
| 139 | run: npm run check |
| 140 | |
| 141 | regression: |
| 142 | # Provider-free input to the regression pass in docs/RELEASE_CHECKLIST.md: |
| 143 | # behaviour statements and feature-docs drift over every commit since the |
| 144 | # last release. It reports and never fails the candidate; a maintainer |
| 145 | # reads the summary next to the per-slice review receipts. |
| 146 | name: Regression report |
| 147 | needs: resolve |
| 148 | if: ${{ !cancelled() && needs.resolve.result == 'success' }} |
| 149 | timeout-minutes: 10 |
| 150 | runs-on: ubuntu-24.04 |
| 151 | steps: |
| 152 | - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 |
| 153 | with: |
| 154 | fetch-depth: 0 |
| 155 | persist-credentials: false |
| 156 | - name: Report unstated behaviour changes since the last release |
| 157 | shell: bash |
| 158 | run: | |
| 159 | set -euo pipefail |
| 160 | head_sha="$(git rev-parse HEAD)" |
| 161 | last_release="" |
| 162 | while read -r tag; do |
| 163 | if [[ "$(git rev-parse "${tag}^{commit}")" != "${head_sha}" ]]; then |
| 164 | last_release="${tag}" |
| 165 | break |
| 166 | fi |
| 167 | done < <(git tag --merged HEAD --sort=-v:refname --list 'v[0-9]*') |
| 168 | if [[ -z "${last_release}" ]]; then |
| 169 | echo "No earlier release tag; nothing to compare." | tee -a "${GITHUB_STEP_SUMMARY}" |
| 170 | exit 0 |
| 171 | fi |
| 172 | { |
| 173 | echo "## Regression report: ${last_release}..$(git rev-parse --short=12 HEAD)" |
| 174 | echo |
| 175 | echo '```text' |
| 176 | python3 scripts/check-behaviour-line.py --warn-only "${last_release}" HEAD 2>&1 |
| 177 | echo |
| 178 | python3 scripts/check-docs-drift.py --warn-only "${last_release}" HEAD 2>&1 |
| 179 | echo '```' |
| 180 | } | tee -a "${GITHUB_STEP_SUMMARY}" |
| 181 | |
| 182 | parity: |
| 183 | # The same gate release.yml runs before publish. release.yml refuses a tag |
| 184 | # unless an RC run for that exact SHA has this job green |
| 185 | # (scripts/release/require-rc-receipt.sh matches the "Parity" name). |
| 186 | name: Parity |
| 187 | needs: resolve |
| 188 | if: ${{ !cancelled() && needs.resolve.result == 'success' }} |
| 189 | uses: ./.github/workflows/release-parity.yml |
| 190 | |
| 191 | artifacts: |
| 192 | permissions: |
| 193 | contents: read |
| 194 | actions: read |
| 195 | needs: [resolve, web] |
| 196 | if: ${{ !cancelled() && needs.resolve.result == 'success' && needs.web.result == 'success' }} |
| 197 | uses: ./.github/workflows/release-artifacts.yml |
| 198 | with: |
| 199 | source_sha: ${{ needs.resolve.outputs.sha }} |
| 200 | version: ${{ needs.resolve.outputs.version }} |
| 201 | compiled_host_delivery: ${{ vars.CODEWHALE_COMPILED_HOST_DELIVERY == '1' }} |
| 202 | compiled_host_run_id: ${{ vars.CODEWHALE_COMPILED_HOST_QUALIFICATION_RUN_ID || '' }} |
| 203 | compiled_host_targets: ${{ vars.CODEWHALE_COMPILED_HOST_TARGETS || 'linux-x64,macos-arm64,windows-x64' }} |
| 204 | retention_days: 7 |
| 205 | macos_runner: ${{ inputs.macos_runner }} |
| 206 | secrets: |
| 207 | CODEWHALE_RELEASE_SIGNING_KEY: ${{ !inputs.nightly && secrets.CODEWHALE_RELEASE_SIGNING_KEY || '' }} |
| 208 |