| 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: 20 |
| 35 | package-manager-cache: false |
| 36 | - uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # 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 | run: | |
| 73 | ./scripts/release/check-versions.sh |
| 74 | ./scripts/release/check-ohos-deps.sh |
| 75 | - name: Reconfirm clean source snapshot |
| 76 | run: git diff --exit-code |
| 77 | |
| 78 | web: |
| 79 | name: Verify exact candidate web surface |
| 80 | timeout-minutes: 15 |
| 81 | needs: resolve |
| 82 | if: ${{ !cancelled() && needs.resolve.result == 'success' }} |
| 83 | runs-on: ubuntu-latest |
| 84 | defaults: |
| 85 | run: |
| 86 | working-directory: web |
| 87 | steps: |
| 88 | # resolve already proved expected_sha equals GITHUB_SHA. Do not |
| 89 | # interpolate that SHA into checkout or the npm cache key. |
| 90 | - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 |
| 91 | - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 |
| 92 | with: |
| 93 | node-version: 22 |
| 94 | cache: npm |
| 95 | cache-dependency-path: web/package-lock.json |
| 96 | - name: Install web dependencies |
| 97 | run: npm ci |
| 98 | - name: Run web tests |
| 99 | run: npm test |
| 100 | - name: Check exact candidate web surface |
| 101 | env: |
| 102 | GITHUB_TOKEN: ${{ github.token }} |
| 103 | run: npm run check |
| 104 | |
| 105 | artifacts: |
| 106 | needs: [resolve, web] |
| 107 | if: ${{ !cancelled() && needs.resolve.result == 'success' && needs.web.result == 'success' }} |
| 108 | uses: ./.github/workflows/release-artifacts.yml |
| 109 | with: |
| 110 | source_sha: ${{ needs.resolve.outputs.sha }} |
| 111 | version: ${{ needs.resolve.outputs.version }} |
| 112 | retention_days: 7 |
| 113 |