返回 CodeWhale
release-candidate.yml
根目录 / .github / workflows / release-candidate.yml
1 name: Release candidate
2
3 # Safe pre-publication artifact proof. This workflow never creates a tag or
4 # release and never writes to a registry, container repository, tap, or deploy.
5 on:
6 workflow_dispatch:
7 inputs:
8 expected_sha:
9 description: Exact 40-character commit selected by --ref (must match the dispatch SHA)
10 required: true
11 type: string
12
13 permissions:
14 contents: read
15
16 concurrency:
17 group: release-candidate-${{ github.sha }}
18 cancel-in-progress: false
19
20 jobs:
21 resolve:
22 name: Resolve exact candidate source
23 timeout-minutes: 10
24 runs-on: ubuntu-latest
25 outputs:
26 sha: ${{ steps.source.outputs.sha }}
27 version: ${{ steps.source.outputs.version }}
28 steps:
29 - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
30 with:
31 fetch-depth: 0
32 - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
33 with:
34 node-version: 22
35 package-manager-cache: false
36 - uses: dtolnay/rust-toolchain@02cb101ec7c40f2c49e1d9714d64511d8e1b74de # stable 2026-07-18
37 with:
38 toolchain: stable
39 - name: Match dispatch to the requested commit
40 id: source
41 shell: bash
42 env:
43 EXPECTED_SHA: ${{ inputs.expected_sha }}
44 run: |
45 set -euo pipefail
46 if [[ "${#EXPECTED_SHA}" -ne 40 || "${EXPECTED_SHA}" =~ [^0-9a-fA-F] ]]; then
47 echo "::error::expected_sha must be a full 40-character commit SHA." >&2
48 exit 1
49 fi
50 actual="$(git rev-parse HEAD)"
51 expected_normalized="$(printf '%s' "${EXPECTED_SHA}" | tr '[:upper:]' '[:lower:]')"
52 if [[ "${actual}" != "${expected_normalized}" ]]; then
53 echo "::error::Dispatch resolved to ${actual}, not requested ${EXPECTED_SHA}." >&2
54 exit 1
55 fi
56
57 workspace_version="$(grep -E '^version = "' Cargo.toml | head -n1 | sed -E 's/^version = "([^"]+)".*/\1/')"
58 npm_version="$(node -p "require('./npm/codewhale/package.json').version")"
59 binary_version="$(node -p "require('./npm/codewhale/package.json').codewhaleBinaryVersion")"
60 if [[ "${workspace_version}" != "${npm_version}" ]]; then
61 echo "::error::Candidate version drift: workspace=${workspace_version}, npm=${npm_version}, binary=${binary_version}." >&2
62 exit 1
63 fi
64 if [[ "${workspace_version}" != "${binary_version}" ]]; then
65 echo "::error::Candidate version drift: workspace=${workspace_version}, npm=${npm_version}, binary=${binary_version}." >&2
66 exit 1
67 fi
68
69 echo "sha=${actual}" >> "${GITHUB_OUTPUT}"
70 echo "version=${workspace_version}" >> "${GITHUB_OUTPUT}"
71 - name: Check version and OHOS release contracts
72 # --require-dated-release, as auto-tag.yml and release.yml run it:
73 # release.yml only accepts an RC receipt for the exact tag SHA, so an
74 # RC on an undated "Unreleased candidate" changelog could never
75 # authorize a release. Fail here, before the long parity and artifact
76 # builds, instead of at tag time.
77 run: |
78 ./scripts/release/check-versions.sh --require-dated-release
79 ./scripts/release/check-ohos-deps.sh
80 - name: Reconfirm clean source snapshot
81 run: git diff --exit-code
82
83 web:
84 name: Verify exact candidate web surface
85 timeout-minutes: 15
86 needs: resolve
87 if: ${{ !cancelled() && needs.resolve.result == 'success' }}
88 runs-on: ubuntu-latest
89 defaults:
90 run:
91 working-directory: web
92 steps:
93 # resolve already proved expected_sha equals GITHUB_SHA. Do not
94 # interpolate that SHA into checkout or the npm cache key.
95 - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
96 with:
97 # `check:facts` derives each model's `addedAt` from the commit date
98 # on which its id first appeared in the model declaration paths
99 # (web/scripts/facts-lib.mjs). A shallow checkout collapses every
100 # date to the tip commit and the committed facts always read as
101 # stale; web.yml and ci.yml pin depth 0 for the same reason.
102 fetch-depth: 0
103 - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
104 with:
105 node-version: 22
106 cache: npm
107 cache-dependency-path: web/package-lock.json
108 - name: Install web dependencies
109 run: npm ci
110 - name: Run web tests
111 run: npm test
112 - name: Check exact candidate web surface
113 env:
114 GITHUB_TOKEN: ${{ github.token }}
115 run: npm run check
116
117 parity:
118 # The same gate release.yml runs before publish. release.yml refuses a tag
119 # unless an RC run for that exact SHA has this job green
120 # (scripts/release/require-rc-receipt.sh matches the "Parity" name).
121 name: Parity
122 needs: resolve
123 if: ${{ !cancelled() && needs.resolve.result == 'success' }}
124 uses: ./.github/workflows/release-parity.yml
125
126 artifacts:
127 permissions:
128 contents: read
129 actions: read
130 needs: [resolve, web]
131 if: ${{ !cancelled() && needs.resolve.result == 'success' && needs.web.result == 'success' }}
132 uses: ./.github/workflows/release-artifacts.yml
133 with:
134 source_sha: ${{ needs.resolve.outputs.sha }}
135 version: ${{ needs.resolve.outputs.version }}
136 compiled_host_delivery: ${{ vars.CODEWHALE_COMPILED_HOST_DELIVERY == '1' }}
137 compiled_host_run_id: ${{ vars.CODEWHALE_COMPILED_HOST_QUALIFICATION_RUN_ID || '' }}
138 compiled_host_targets: ${{ vars.CODEWHALE_COMPILED_HOST_TARGETS || 'linux-x64,macos-arm64,windows-x64' }}
139 retention_days: 7
140
140 lines YAML