Skip to content

Commit df9f3b7

Browse files
build: VERSIONS extension + setup-toolchain action + sync-versions
Foundation pieces for the artifact build system: - Extend sdk/runanywhere-commons/VERSIONS with NDK, Emscripten, Node, Java, Gradle, CMake versions. Removes the need to hardcode these in workflow files (currently duplicated in 5+ places). - LoadVersions.cmake + load-versions.sh log the new keys. - New composite action .github/actions/setup-toolchain/action.yml that loads VERSIONS into $GITHUB_ENV and installs the right toolchain per platform input (ios/macos/android/linux/windows/web/sdk-only). One source of truth for tool versions across all workflows. - New scripts/sync-versions.sh that bumps the version string in every manifest in the monorepo (commons VERSION/VERSIONS, root Package.swift sdkVersion, kotlin gradle.properties, all package.json across web/RN, all pubspec.yaml across flutter packages). Smoke-tested end to end. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent bc7db9b commit df9f3b7

5 files changed

Lines changed: 287 additions & 0 deletions

File tree

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Setup Toolchain
2+
description: |
3+
Loads sdk/runanywhere-commons/VERSIONS into $GITHUB_ENV and installs the
4+
per-platform toolchain (Xcode, NDK, JDK, Node, Emscripten, CMake) at the
5+
versions pinned in VERSIONS. Single source of truth for tool versions.
6+
7+
inputs:
8+
platform:
9+
required: true
10+
description: 'ios | macos | android | linux | windows | web | sdk-only'
11+
12+
runs:
13+
using: composite
14+
steps:
15+
# ----------------------------------------------------------------------
16+
# 1. Load VERSIONS into $GITHUB_ENV so subsequent steps see the values.
17+
# ----------------------------------------------------------------------
18+
- name: Load VERSIONS into env
19+
shell: bash
20+
run: |
21+
set -euo pipefail
22+
VERSIONS_FILE="${GITHUB_WORKSPACE}/sdk/runanywhere-commons/VERSIONS"
23+
if [ ! -f "$VERSIONS_FILE" ]; then
24+
echo "::error::VERSIONS file not found at $VERSIONS_FILE"
25+
exit 1
26+
fi
27+
# Strip comments + blank lines, keep KEY=VALUE only
28+
grep -E '^[A-Z_][A-Z0-9_]*=' "$VERSIONS_FILE" | while IFS='=' read -r k v; do
29+
# Trim surrounding whitespace (xargs handles this)
30+
k="$(echo "$k" | xargs)"
31+
v="$(echo "$v" | xargs)"
32+
echo "$k=$v" >> "$GITHUB_ENV"
33+
done
34+
echo "::group::Loaded versions"
35+
cat "$VERSIONS_FILE" | grep -E '^[A-Z_][A-Z0-9_]*='
36+
echo "::endgroup::"
37+
38+
# ----------------------------------------------------------------------
39+
# 2. Per-platform toolchain installation (uses env vars from step 1).
40+
# ----------------------------------------------------------------------
41+
- name: Setup Xcode (iOS/macOS)
42+
if: inputs.platform == 'ios' || inputs.platform == 'macos'
43+
uses: maxim-lobanov/setup-xcode@v1
44+
with:
45+
xcode-version: ${{ env.XCODE_VERSION }}
46+
47+
- name: Setup JDK (Android/SDK)
48+
if: inputs.platform == 'android' || inputs.platform == 'sdk-only'
49+
uses: actions/setup-java@v4
50+
with:
51+
distribution: temurin
52+
java-version: ${{ env.JAVA_VERSION }}
53+
54+
- name: Setup Android SDK + NDK (Android)
55+
if: inputs.platform == 'android'
56+
uses: android-actions/setup-android@v3
57+
58+
- name: Install pinned Android NDK
59+
if: inputs.platform == 'android'
60+
shell: bash
61+
run: |
62+
set -euo pipefail
63+
echo "y" | sdkmanager --install "ndk;${NDK_VERSION}" >/dev/null
64+
echo "ANDROID_NDK_HOME=${ANDROID_HOME}/ndk/${NDK_VERSION}" >> "$GITHUB_ENV"
65+
echo "ANDROID_NDK_ROOT=${ANDROID_HOME}/ndk/${NDK_VERSION}" >> "$GITHUB_ENV"
66+
67+
- name: Setup Node (Web/RN/SDK)
68+
if: inputs.platform == 'web' || inputs.platform == 'sdk-only'
69+
uses: actions/setup-node@v4
70+
with:
71+
node-version: ${{ env.NODE_VERSION }}
72+
73+
- name: Setup Emscripten (Web)
74+
if: inputs.platform == 'web'
75+
uses: mymindstorm/setup-emsdk@v14
76+
with:
77+
version: ${{ env.EMSCRIPTEN_VERSION }}
78+
actions-cache-folder: emsdk-cache
79+
80+
- name: Setup CMake (Linux/Windows native)
81+
if: inputs.platform == 'linux' || inputs.platform == 'windows'
82+
uses: jwlawson/actions-setup-cmake@v2
83+
with:
84+
cmake-version: ${{ env.CMAKE_VERSION }}
85+
86+
- name: Install Linux build deps
87+
if: inputs.platform == 'linux'
88+
shell: bash
89+
run: |
90+
sudo apt-get update -qq
91+
sudo apt-get install -y --no-install-recommends \
92+
build-essential ninja-build pkg-config
93+
94+
- name: Print toolchain summary
95+
shell: bash
96+
run: |
97+
echo "::group::Toolchain summary for platform=${{ inputs.platform }}"
98+
command -v xcodebuild >/dev/null 2>&1 && xcodebuild -version || true
99+
command -v javac >/dev/null 2>&1 && javac -version || true
100+
command -v node >/dev/null 2>&1 && node --version || true
101+
command -v emcc >/dev/null 2>&1 && emcc --version | head -1 || true
102+
command -v cmake >/dev/null 2>&1 && cmake --version | head -1 || true
103+
echo "ANDROID_NDK_HOME=${ANDROID_NDK_HOME:-unset}"
104+
echo "::endgroup::"

scripts/sync-versions.sh

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
#!/usr/bin/env bash
2+
# =============================================================================
3+
# sync-versions.sh
4+
# =============================================================================
5+
# Single-source version bump across the monorepo. Updates every manifest that
6+
# carries a version string so they all match the requested release version.
7+
#
8+
# Usage:
9+
# scripts/sync-versions.sh <new_version>
10+
#
11+
# Example:
12+
# scripts/sync-versions.sh 0.20.0
13+
# scripts/sync-versions.sh v0.20.0 # 'v' prefix is stripped
14+
#
15+
# What it touches:
16+
# sdk/runanywhere-commons/VERSION (single line)
17+
# sdk/runanywhere-commons/VERSIONS (PROJECT_VERSION line)
18+
# Package.swift (sdkVersion line)
19+
# sdk/runanywhere-kotlin/gradle.properties (runanywhere.nativeLibVersion)
20+
# sdk/runanywhere-web/package.json (root version)
21+
# sdk/runanywhere-web/packages/*/package.json (each package version)
22+
# sdk/runanywhere-react-native/package.json (root)
23+
# sdk/runanywhere-react-native/packages/*/package.json (each package)
24+
# sdk/runanywhere-flutter/packages/*/pubspec.yaml (each version: line)
25+
#
26+
# Does NOT touch (intentional):
27+
# - SwiftPM XCFramework checksums (use sync-checksums.sh after release artifacts exist)
28+
# - VERSIONS file dependency versions (those track upstream library versions, not our release)
29+
# =============================================================================
30+
31+
set -euo pipefail
32+
33+
if [ $# -ne 1 ]; then
34+
echo "Usage: $0 <new_version>" >&2
35+
echo "Example: $0 0.20.0" >&2
36+
exit 1
37+
fi
38+
39+
# Strip leading 'v' if present
40+
NEW_VERSION="${1#v}"
41+
42+
# Validate semver-ish format
43+
if ! [[ "$NEW_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.-][A-Za-z0-9.-]+)?$ ]]; then
44+
echo "ERROR: '$NEW_VERSION' does not look like a semver version" >&2
45+
exit 1
46+
fi
47+
48+
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
49+
50+
bump_line() {
51+
# Replaces a line matching $pattern with $replacement, in $file.
52+
# Cross-platform sed -i (BSD sed on macOS needs '' after -i).
53+
local file="$1" pattern="$2" replacement="$3"
54+
if [ ! -f "$file" ]; then
55+
echo " skip (not found): $file"
56+
return 0
57+
fi
58+
if [[ "$OSTYPE" == "darwin"* ]]; then
59+
sed -i '' -E "s|${pattern}|${replacement}|" "$file"
60+
else
61+
sed -i -E "s|${pattern}|${replacement}|" "$file"
62+
fi
63+
echo " bumped: $file"
64+
}
65+
66+
bump_json_version() {
67+
local file="$1"
68+
bump_line "$file" '"version": "[^"]+"' "\"version\": \"${NEW_VERSION}\""
69+
}
70+
71+
bump_pubspec_version() {
72+
local file="$1"
73+
bump_line "$file" '^version: .+' "version: ${NEW_VERSION}"
74+
}
75+
76+
echo ">> Syncing versions to ${NEW_VERSION}"
77+
echo ">> Repo root: ${REPO_ROOT}"
78+
echo ""
79+
80+
# 1. commons VERSION + VERSIONS
81+
echo ">> commons:"
82+
echo "$NEW_VERSION" > "${REPO_ROOT}/sdk/runanywhere-commons/VERSION"
83+
echo " bumped: sdk/runanywhere-commons/VERSION"
84+
bump_line "${REPO_ROOT}/sdk/runanywhere-commons/VERSIONS" \
85+
'^PROJECT_VERSION=.*' "PROJECT_VERSION=${NEW_VERSION}"
86+
87+
# 2. Swift Package.swift (root)
88+
echo ""
89+
echo ">> Swift SDK:"
90+
bump_line "${REPO_ROOT}/Package.swift" \
91+
'let sdkVersion = "[^"]+"' "let sdkVersion = \"${NEW_VERSION}\""
92+
93+
# 3. Kotlin gradle.properties
94+
echo ""
95+
echo ">> Kotlin SDK:"
96+
KOTLIN_PROPS="${REPO_ROOT}/sdk/runanywhere-kotlin/gradle.properties"
97+
if [ -f "$KOTLIN_PROPS" ]; then
98+
if grep -q '^runanywhere\.nativeLibVersion=' "$KOTLIN_PROPS"; then
99+
bump_line "$KOTLIN_PROPS" \
100+
'^runanywhere\.nativeLibVersion=.*' "runanywhere.nativeLibVersion=${NEW_VERSION}"
101+
else
102+
echo "runanywhere.nativeLibVersion=${NEW_VERSION}" >> "$KOTLIN_PROPS"
103+
echo " appended: runanywhere.nativeLibVersion to $KOTLIN_PROPS"
104+
fi
105+
if grep -q '^SDK_VERSION=' "$KOTLIN_PROPS"; then
106+
bump_line "$KOTLIN_PROPS" \
107+
'^SDK_VERSION=.*' "SDK_VERSION=${NEW_VERSION}"
108+
fi
109+
fi
110+
111+
# 4. Web SDK packages
112+
echo ""
113+
echo ">> Web SDK:"
114+
for pkg in \
115+
"${REPO_ROOT}/sdk/runanywhere-web/package.json" \
116+
"${REPO_ROOT}/sdk/runanywhere-web/packages/core/package.json" \
117+
"${REPO_ROOT}/sdk/runanywhere-web/packages/llamacpp/package.json" \
118+
"${REPO_ROOT}/sdk/runanywhere-web/packages/onnx/package.json"; do
119+
bump_json_version "$pkg"
120+
done
121+
122+
# 5. React Native SDK packages
123+
echo ""
124+
echo ">> React Native SDK:"
125+
for pkg in \
126+
"${REPO_ROOT}/sdk/runanywhere-react-native/package.json" \
127+
"${REPO_ROOT}/sdk/runanywhere-react-native/packages/core/package.json" \
128+
"${REPO_ROOT}/sdk/runanywhere-react-native/packages/llamacpp/package.json" \
129+
"${REPO_ROOT}/sdk/runanywhere-react-native/packages/onnx/package.json"; do
130+
bump_json_version "$pkg"
131+
done
132+
133+
# 6. Flutter SDK packages
134+
echo ""
135+
echo ">> Flutter SDK:"
136+
for pkg in \
137+
"${REPO_ROOT}/sdk/runanywhere-flutter/packages/runanywhere/pubspec.yaml" \
138+
"${REPO_ROOT}/sdk/runanywhere-flutter/packages/runanywhere_llamacpp/pubspec.yaml" \
139+
"${REPO_ROOT}/sdk/runanywhere-flutter/packages/runanywhere_onnx/pubspec.yaml"; do
140+
bump_pubspec_version "$pkg"
141+
done
142+
143+
echo ""
144+
echo ">> Done. Verify with:"
145+
echo " git diff -- sdk/ Package.swift"
146+
echo ""
147+
echo ">> Then commit, tag, and push:"
148+
echo " git add -u"
149+
echo " git commit -m \"chore: release ${NEW_VERSION}\""
150+
echo " git tag v${NEW_VERSION}"
151+
echo " git push origin main v${NEW_VERSION}"

sdk/runanywhere-commons/VERSIONS

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,24 @@ ANDROID_MIN_SDK=24
3131
# Xcode version for CI/CD builds
3232
XCODE_VERSION=15.4
3333

34+
# Android NDK (matches what scripts/build-android.sh and Kotlin SDK expect)
35+
NDK_VERSION=27.0.12077973
36+
37+
# Emscripten SDK (used by sdk/runanywhere-web/wasm/scripts/build.sh)
38+
EMSCRIPTEN_VERSION=3.1.51
39+
40+
# Node (Web SDK + React Native SDK builds)
41+
NODE_VERSION=20
42+
43+
# JDK (Kotlin SDK + Android builds)
44+
JAVA_VERSION=17
45+
46+
# Gradle wrapper version baseline
47+
GRADLE_VERSION=8.11.1
48+
49+
# CMake minimum version (matches sdk/runanywhere-commons/CMakeLists.txt:1)
50+
CMAKE_VERSION=3.22
51+
3452
# =============================================================================
3553
# ONNX Runtime
3654
# =============================================================================

sdk/runanywhere-commons/cmake/LoadVersions.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,10 @@ message(STATUS " SHERPA_ONNX_VERSION_WINDOWS: ${RAC_SHERPA_ONNX_VERSION_WINDO
6666
message(STATUS " Other:")
6767
message(STATUS " LLAMACPP_VERSION: ${RAC_LLAMACPP_VERSION}")
6868
message(STATUS " NLOHMANN_JSON_VERSION: ${RAC_NLOHMANN_JSON_VERSION}")
69+
message(STATUS " Toolchain:")
70+
message(STATUS " NDK_VERSION: ${RAC_NDK_VERSION}")
71+
message(STATUS " EMSCRIPTEN_VERSION: ${RAC_EMSCRIPTEN_VERSION}")
72+
message(STATUS " NODE_VERSION: ${RAC_NODE_VERSION}")
73+
message(STATUS " JAVA_VERSION: ${RAC_JAVA_VERSION}")
74+
message(STATUS " GRADLE_VERSION: ${RAC_GRADLE_VERSION}")
75+
message(STATUS " CMAKE_VERSION: ${RAC_CMAKE_VERSION}")

sdk/runanywhere-commons/scripts/load-versions.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ if [ "${VERBOSE:-}" = "1" ]; then
6969
echo " LLAMACPP_VERSION=${LLAMACPP_VERSION}"
7070
echo " NLOHMANN_JSON_VERSION=${NLOHMANN_JSON_VERSION}"
7171
echo " RAC_COMMONS_VERSION=${RAC_COMMONS_VERSION}"
72+
echo " Toolchain:"
73+
echo " NDK_VERSION=${NDK_VERSION}"
74+
echo " EMSCRIPTEN_VERSION=${EMSCRIPTEN_VERSION}"
75+
echo " NODE_VERSION=${NODE_VERSION}"
76+
echo " JAVA_VERSION=${JAVA_VERSION}"
77+
echo " GRADLE_VERSION=${GRADLE_VERSION}"
78+
echo " CMAKE_VERSION=${CMAKE_VERSION}"
7279
fi
7380

7481
# Clean up temporary variables

0 commit comments

Comments
 (0)