Skip to content

Commit 608bf8d

Browse files
committed
fix(ci): build npm binaries from release ref and verify version
1 parent eeb4ac1 commit 608bf8d

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

.github/workflows/build-cli-binaries.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@ name: Build CLI Binaries
22

33
on:
44
workflow_call:
5+
inputs:
6+
ref:
7+
description: 'Git ref (tag or branch) to checkout'
8+
required: false
9+
type: string
510
workflow_dispatch:
11+
inputs:
12+
ref:
13+
description: 'Git ref (tag or branch) to checkout'
14+
required: false
15+
type: string
616

717
env:
818
CARGO_TERM_COLOR: always
@@ -39,6 +49,8 @@ jobs:
3949
runs-on: ${{ matrix.os }}
4050
steps:
4151
- uses: actions/checkout@v6
52+
with:
53+
ref: ${{ inputs.ref || github.ref }}
4254

4355
- name: Install build dependencies (Ubuntu)
4456
if: matrix.os == 'ubuntu-latest'

.github/workflows/publish-npm.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ on:
1919
jobs:
2020
build-binaries:
2121
name: Build CLI Binaries
22+
# Build artifacts from the same ref as publish checkout to avoid stale binaries.
2223
uses: ./.github/workflows/build-cli-binaries.yml
24+
with:
25+
ref: ${{ inputs.ref }}
2326

2427
publish:
2528
name: Publish to npm
@@ -98,6 +101,29 @@ jobs:
98101
chmod +x packages/cli-node-linux-x64-musl/bin/occ
99102
chmod +x packages/cli-node-linux-arm64-musl/bin/occ
100103
104+
- name: Validate CLI binary version matches release version
105+
run: |
106+
set -euo pipefail
107+
108+
version_output="$(packages/cli-node-linux-x64/bin/occ --version)"
109+
actual_version="$(printf '%s\n' "${version_output}" | awk '/^opencode-cloud / {print $2; exit}')"
110+
expected_version="${{ inputs.version }}"
111+
112+
if [[ -z "${actual_version}" ]]; then
113+
echo "Error: Failed to parse CLI version from linux-x64 binary output: ${version_output}"
114+
exit 1
115+
fi
116+
117+
if [[ "${actual_version}" != "${expected_version}" ]]; then
118+
echo "Error: CLI binary version mismatch."
119+
echo "Expected: ${expected_version}"
120+
echo "Actual: ${actual_version}"
121+
echo "Output: ${version_output}"
122+
exit 1
123+
fi
124+
125+
echo "CLI binary version check passed: ${actual_version}"
126+
101127
- name: Verify packaged binary permissions
102128
run: bash scripts/verify-cli-node-pack-perms.sh
103129

0 commit comments

Comments
 (0)