Skip to content

chore(release): v0.13.5 #28

chore(release): v0.13.5

chore(release): v0.13.5 #28

Workflow file for this run

name: Publish Native Packages
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
dry_run:
description: "Dry run (skip actual publish)"
required: false
default: "true"
type: choice
options:
- "true"
- "false"
permissions:
contents: read
env:
DRY_RUN: ${{ github.event.inputs.dry_run || 'false' }}
jobs:
build:
name: Build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-pc-windows-msvc
os: windows-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24.x
cache: "npm"
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross-compilation tools (aarch64-linux-gnu)
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
- name: Install cross-compilation tools (x86_64-linux-musl)
if: matrix.target == 'x86_64-unknown-linux-musl'
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
- name: Cache Cargo registry
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
native/target
key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('native/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.target }}-cargo-
- name: Install dependencies
run: npm ci --ignore-scripts --legacy-peer-deps
- name: Setup tree-sitter
uses: ./.github/actions/setup-tree-sitter
- name: Build native addon
run: npx napi build --release --cargo-cwd native --config native/package.json --target ${{ matrix.target }} native
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: bindings-${{ matrix.target }}
path: native/*.node
if-no-files-found: error
publish:
name: Publish
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24.x
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: npm ci --ignore-scripts --legacy-peer-deps
- name: Setup tree-sitter
uses: ./.github/actions/setup-tree-sitter
- name: Download all artifacts
uses: actions/download-artifact@v7
with:
path: native/artifacts
- name: List downloaded artifacts
run: ls -R native/artifacts
- name: Move artifacts to npm directories
shell: bash
run: |
# Move each platform binary to its npm package directory
declare -A TARGET_MAP=(
["x86_64-pc-windows-msvc"]="win32-x64-msvc"
["x86_64-apple-darwin"]="darwin-x64"
["aarch64-apple-darwin"]="darwin-arm64"
["x86_64-unknown-linux-gnu"]="linux-x64-gnu"
["x86_64-unknown-linux-musl"]="linux-x64-musl"
["aarch64-unknown-linux-gnu"]="linux-arm64-gnu"
)
declare -A NODE_FILE_MAP=(
["x86_64-pc-windows-msvc"]="sdl-mcp-native.win32-x64-msvc.node"
["x86_64-apple-darwin"]="sdl-mcp-native.darwin-x64.node"
["aarch64-apple-darwin"]="sdl-mcp-native.darwin-arm64.node"
["x86_64-unknown-linux-gnu"]="sdl-mcp-native.linux-x64-gnu.node"
["x86_64-unknown-linux-musl"]="sdl-mcp-native.linux-x64-musl.node"
["aarch64-unknown-linux-gnu"]="sdl-mcp-native.linux-arm64-gnu.node"
)
for target in "${!TARGET_MAP[@]}"; do
npm_dir="${TARGET_MAP[$target]}"
node_file="${NODE_FILE_MAP[$target]}"
src_dir="native/artifacts/bindings-${target}"
echo "Processing ${target} -> native/npm/${npm_dir}/${node_file}"
# Find the .node file (napi names it sdl-mcp-native.node)
src_file=$(find "${src_dir}" -name "*.node" -type f | head -n 1)
if [ -n "${src_file}" ]; then
cp "${src_file}" "native/npm/${npm_dir}/${node_file}"
echo " Copied ${src_file} -> native/npm/${npm_dir}/${node_file}"
else
echo " ERROR: No .node file found in ${src_dir}"
ls -la "${src_dir}" || true
exit 1
fi
done
- name: Verify artifacts
shell: bash
run: |
echo "Verifying all platform packages have binaries..."
MISSING=0
for dir in native/npm/*/; do
pkg_name=$(node -e "console.log(require('./${dir}package.json').name)")
node_files=$(find "${dir}" -name "*.node" -type f | wc -l)
if [ "${node_files}" -eq 0 ]; then
echo " MISSING: ${pkg_name} (${dir})"
MISSING=1
else
size=$(du -h "${dir}"*.node | cut -f1)
echo " OK: ${pkg_name} (${size})"
fi
done
if [ "${MISSING}" -eq 1 ]; then
echo "ERROR: Some platform packages are missing binaries"
exit 1
fi
- name: Publish platform packages
shell: bash
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
FAILED=0
for dir in native/npm/*/; do
pkg_name=$(node -e "console.log(require('./${dir}package.json').name)")
pkg_version=$(node -e "console.log(require('./${dir}package.json').version)")
echo "Publishing ${pkg_name}@${pkg_version}..."
if [ "${DRY_RUN}" = "true" ]; then
echo " [DRY RUN] npm publish ${dir} --access public"
npm publish "${dir}" --access public --dry-run
else
# Check if already published
EXISTING=$(npm view "${pkg_name}@${pkg_version}" version 2>/dev/null || echo "")
if [ "${EXISTING}" = "${pkg_version}" ]; then
echo " SKIP: ${pkg_name}@${pkg_version} already published"
else
if npm publish "${dir}" --access public; then
echo " OK: ${pkg_name}@${pkg_version} published"
else
echo " FAIL: ${pkg_name}@${pkg_version} publish failed"
FAILED=1
fi
fi
fi
done
if [ "${FAILED}" -eq 1 ]; then
echo "WARNING: Some platform packages failed to publish"
exit 1
fi
- name: Publish umbrella package
shell: bash
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
PKG_VERSION=$(node -e "console.log(require('./native/package.json').version)")
echo "Publishing sdl-mcp-native@${PKG_VERSION}..."
if [ "${DRY_RUN}" = "true" ]; then
echo " [DRY RUN] npm publish native/ --access public"
npm publish native/ --access public --dry-run
else
EXISTING=$(npm view "sdl-mcp-native@${PKG_VERSION}" version 2>/dev/null || echo "")
if [ "${EXISTING}" = "${PKG_VERSION}" ]; then
echo " SKIP: sdl-mcp-native@${PKG_VERSION} already published"
else
npm publish native/ --access public --ignore-scripts
fi
fi