Skip to content

Commit c4d32ac

Browse files
committed
chore(ci): build and release the Rust client
1 parent 3879fe3 commit c4d32ac

1 file changed

Lines changed: 94 additions & 0 deletions

File tree

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: cli-rs release
2+
3+
# Builds opencode-native, the Rust client in packages/cli-rs, natively on each runner below and keeps each archive as an
4+
# artifact. A cli-rs-v<version> tag also publishes them as a GitHub release. It never becomes Latest: the monorepo's
5+
# Latest release drives OpenCode's own update paths.
6+
on:
7+
push:
8+
tags:
9+
- "cli-rs-v*"
10+
pull_request:
11+
paths:
12+
- .github/workflows/release-cli-rs.yml
13+
workflow_dispatch:
14+
15+
permissions:
16+
contents: read
17+
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
21+
22+
jobs:
23+
build:
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
include:
28+
# The Linux builds need the runner's glibc, 2.35, or newer.
29+
- { runner: ubuntu-22.04, target: x86_64-unknown-linux-gnu }
30+
- { runner: ubuntu-22.04-arm, target: aarch64-unknown-linux-gnu }
31+
- { runner: macos-15-intel, target: x86_64-apple-darwin }
32+
- { runner: macos-15, target: aarch64-apple-darwin }
33+
- { runner: windows-2025, target: x86_64-pc-windows-msvc, exe: .exe }
34+
runs-on: ${{ matrix.runner }}
35+
timeout-minutes: 60
36+
defaults:
37+
run:
38+
shell: bash
39+
working-directory: packages/cli-rs
40+
env:
41+
OPENCODE_NATIVE_COMMIT: ${{ github.sha }}
42+
CARGO_PROFILE_DIST_STRIP: symbols
43+
MACOSX_DEPLOYMENT_TARGET: "13.0"
44+
# No Visual C++ runtime to install beside the .exe.
45+
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUSTFLAGS: -C target-feature=+crt-static
46+
steps:
47+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
48+
with:
49+
persist-credentials: false
50+
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
51+
with:
52+
bun-version-file: package.json
53+
# The version opencode-native --version prints: the tag's, or 0.0.0-<commit> for any other run.
54+
- name: Version
55+
run: |
56+
version=0.0.0-$GITHUB_SHA
57+
if [[ $GITHUB_REF == refs/tags/cli-rs-v* ]]; then version=${GITHUB_REF_NAME#cli-rs-v}; fi
58+
echo "OPENCODE_VERSION=$version" >> "$GITHUB_ENV"
59+
# rustup reads rust-toolchain.toml; `bun run cargo` first fetches OpenTUI's native library from its release.
60+
- run: rustup toolchain install
61+
- run: bun run cargo build --locked --profile dist --bin opencode-native
62+
- name: Package
63+
run: |
64+
name=opencode-native-$OPENCODE_VERSION-${{ matrix.target }}
65+
mkdir -p "dist/$name"
66+
cp "target/dist/opencode-native${{ matrix.exe }}" "dist/$name/"
67+
tar -C dist -czf "dist/$name.tar.gz" "$name"
68+
ls -l "dist/$name" "dist/$name.tar.gz"
69+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
70+
with:
71+
name: opencode-native-${{ matrix.target }}
72+
path: packages/cli-rs/dist/*.tar.gz
73+
if-no-files-found: error
74+
compression-level: 0
75+
76+
release:
77+
needs: build
78+
if: startsWith(github.ref, 'refs/tags/cli-rs-v')
79+
runs-on: ubuntu-24.04
80+
permissions:
81+
contents: write
82+
steps:
83+
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
84+
with:
85+
pattern: opencode-native-*
86+
merge-multiple: true
87+
- name: Publish
88+
env:
89+
GH_TOKEN: ${{ github.token }}
90+
run: |
91+
sha256sum ./*.tar.gz > SHA256SUMS
92+
gh release create "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --verify-tag --latest=false \
93+
--title "opencode-native ${GITHUB_REF_NAME#cli-rs-v}" --notes "The Rust client (packages/cli-rs) at $GITHUB_SHA." \
94+
./*.tar.gz SHA256SUMS

0 commit comments

Comments
 (0)