chore(ci): build and release the Rust client

This commit is contained in:
Simon Klee 2026-11-24 19:44:05 +01:00
parent ae73590cf7
commit b652ad3cc8
No known key found for this signature in database
GPG key ID: B91696044D47BEA3

94
.github/workflows/release-cli-rs.yml vendored Normal file
View file

@ -0,0 +1,94 @@
name: cli-rs release
# Builds opencode-native, the Rust client in packages/cli-rs, natively on each runner below and keeps each archive as an
# artifact. A cli-rs-v<version> tag also publishes them as a GitHub release. It never becomes Latest: the monorepo's
# Latest release drives OpenCode's own update paths.
on:
push:
tags:
- "cli-rs-v*"
pull_request:
paths:
- .github/workflows/release-cli-rs.yml
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
# The Linux builds need the runner's glibc, 2.35, or newer.
- { runner: ubuntu-22.04, target: x86_64-unknown-linux-gnu }
- { runner: ubuntu-22.04-arm, target: aarch64-unknown-linux-gnu }
- { runner: macos-15-intel, target: x86_64-apple-darwin }
- { runner: macos-15, target: aarch64-apple-darwin }
- { runner: windows-2025, target: x86_64-pc-windows-msvc, exe: .exe }
runs-on: ${{ matrix.runner }}
timeout-minutes: 60
defaults:
run:
shell: bash
working-directory: packages/cli-rs
env:
OPENCODE_NATIVE_COMMIT: ${{ github.sha }}
CARGO_PROFILE_DIST_STRIP: symbols
MACOSX_DEPLOYMENT_TARGET: "13.0"
# No Visual C++ runtime to install beside the .exe.
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUSTFLAGS: -C target-feature=+crt-static
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
persist-credentials: false
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version-file: package.json
# The version opencode-native --version prints: the tag's, or 0.0.0-<commit> for any other run.
- name: Version
run: |
version=0.0.0-$GITHUB_SHA
if [[ $GITHUB_REF == refs/tags/cli-rs-v* ]]; then version=${GITHUB_REF_NAME#cli-rs-v}; fi
echo "OPENCODE_VERSION=$version" >> "$GITHUB_ENV"
# rustup reads rust-toolchain.toml; `bun run cargo` first fetches OpenTUI's native library from its release.
- run: rustup toolchain install
- run: bun run cargo build --locked --profile dist --bin opencode-native
- name: Package
run: |
name=opencode-native-$OPENCODE_VERSION-${{ matrix.target }}
mkdir -p "dist/$name"
cp "target/dist/opencode-native${{ matrix.exe }}" "dist/$name/"
tar -C dist -czf "dist/$name.tar.gz" "$name"
ls -l "dist/$name" "dist/$name.tar.gz"
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: opencode-native-${{ matrix.target }}
path: packages/cli-rs/dist/*.tar.gz
if-no-files-found: error
compression-level: 0
release:
needs: build
if: startsWith(github.ref, 'refs/tags/cli-rs-v')
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
pattern: opencode-native-*
merge-multiple: true
- name: Publish
env:
GH_TOKEN: ${{ github.token }}
run: |
sha256sum ./*.tar.gz > SHA256SUMS
gh release create "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --verify-tag --latest=false \
--title "opencode-native ${GITHUB_REF_NAME#cli-rs-v}" --notes "The Rust client (packages/cli-rs) at $GITHUB_SHA." \
./*.tar.gz SHA256SUMS