Skip to content

V0.6.2 -V 0.8.0 (-#39) #22

V0.6.2 -V 0.8.0 (-#39)

V0.6.2 -V 0.8.0 (-#39) #22

Workflow file for this run

name: Release npm
on:
push:
tags:
- 'npm/v*'
permissions:
contents: write
id-token: write
jobs:
verify-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract.outputs.version }}
matches: ${{ steps.check.outputs.matches }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref }}
- name: Extract version from tag
id: extract
run: |
TAG="${GITHUB_REF#refs/tags/npm/v}"
echo "version=$TAG" >> $GITHUB_OUTPUT
- name: Check package.json version matches tag
id: check
run: |
PKG_VERSION=$(node -p "require('./jacsnpm/package.json').version")
TAG_VERSION="${{ steps.extract.outputs.version }}"
echo "Package version: $PKG_VERSION"
echo "Tag version: $TAG_VERSION"
if [ "$PKG_VERSION" = "$TAG_VERSION" ]; then
echo "matches=true" >> $GITHUB_OUTPUT
else
echo "::error::Version mismatch! package.json has $PKG_VERSION but tag is $TAG_VERSION"
echo "matches=false" >> $GITHUB_OUTPUT
exit 1
fi
build:
needs: verify-version
continue-on-error: ${{ matrix.allow_failure }}
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
target: aarch64-apple-darwin
use_zig: false
allow_failure: false
- os: macos-14
target: x86_64-apple-darwin
use_zig: false
allow_failure: false
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
use_zig: false
allow_failure: false
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
use_zig: true
allow_failure: false
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
use_zig: false
allow_failure: false
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-musl
use_zig: false
allow_failure: true
- os: ubuntu-latest
target: armv7-unknown-linux-gnueabihf
use_zig: true
allow_failure: true
- os: ubuntu-latest
target: armv7-unknown-linux-musleabihf
use_zig: true
allow_failure: true
- os: ubuntu-latest
target: riscv64gc-unknown-linux-gnu
use_zig: true
allow_failure: true
- os: ubuntu-latest
target: riscv64gc-unknown-linux-musl
use_zig: true
allow_failure: true
- os: ubuntu-latest
target: s390x-unknown-linux-gnu
use_zig: true
allow_failure: true
- os: ubuntu-latest
target: x86_64-unknown-freebsd
use_zig: true
allow_failure: true
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref }}
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
target: ${{ matrix.target }}
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Install musl toolchain
if: contains(matrix.target, 'musl') && !matrix.use_zig
run: sudo apt-get update && sudo apt-get install -y musl-tools
- name: Install Zig
if: ${{ matrix.use_zig }}
uses: goto-bus-stop/setup-zig@v2
with:
version: 0.13.0
- name: Install dependencies
run: npm install
working-directory: jacsnpm
- name: Set musl CC for native ARM builds
if: contains(matrix.target, 'aarch64') && contains(matrix.target, 'musl') && !matrix.use_zig
run: |
echo "CC_aarch64_unknown_linux_musl=musl-gcc" >> $GITHUB_ENV
echo "AR_aarch64_unknown_linux_musl=ar" >> $GITHUB_ENV
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc" >> $GITHUB_ENV
- name: Build native module
working-directory: jacsnpm
shell: bash
run: |
if [ "${{ matrix.use_zig }}" = "true" ]; then
npx napi build --platform --release --target ${{ matrix.target }} --zig
else
npx napi build --platform --release --target ${{ matrix.target }}
fi
- uses: actions/upload-artifact@v4
with:
name: bindings-${{ matrix.target }}
path: jacsnpm/*.node
publish:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref }}
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
- name: Install dependencies and build JS files
working-directory: jacsnpm
run: |
npm install
npm run build
- uses: actions/download-artifact@v4
with:
path: jacsnpm/artifacts
- name: Copy binaries
run: |
find artifacts -name "*.node" -type f -print -exec cp {} . \;
ls -1 *.node
working-directory: jacsnpm
- name: Verify required package files exist
run: |
set -euo pipefail
REQUIRED_FILES=(
"index.js"
"index.d.ts"
"simple.js"
"simple.d.ts"
"mcp.js"
"mcp.d.ts"
"http.js"
"http.d.ts"
"src/a2a.js"
"src/a2a.d.ts"
"package.json"
)
REQUIRED_BINARIES=(
"jacs.darwin-arm64.node"
"jacs.darwin-x64.node"
"jacs.linux-x64-gnu.node"
"jacs.linux-x64-musl.node"
"jacs.linux-arm64-gnu.node"
)
OPTIONAL_BINARIES=(
"jacs.linux-arm64-musl.node"
"jacs.win32-x64-msvc.node"
"jacs.win32-ia32-msvc.node"
"jacs.win32-arm64-msvc.node"
"jacs.linux-arm-gnueabihf.node"
"jacs.linux-arm-musleabihf.node"
"jacs.linux-riscv64-gnu.node"
"jacs.linux-riscv64-musl.node"
"jacs.linux-s390x-gnu.node"
"jacs.freebsd-x64.node"
)
for file in "${REQUIRED_FILES[@]}"; do
test -f "$file" || { echo "::error::Missing required file: $file"; exit 1; }
done
for file in "${REQUIRED_BINARIES[@]}"; do
test -f "$file" || { echo "::error::Missing required native binary: $file"; exit 1; }
done
for file in "${OPTIONAL_BINARIES[@]}"; do
if [ ! -f "$file" ]; then
echo "::warning::Optional native binary not present: $file"
fi
done
working-directory: jacsnpm
- name: Validate npm pack output
run: |
set -euo pipefail
npm pack --dry-run 2>&1 | tee pack-dry-run.txt
REQUIRED_PACKED_FILES=(
"index.js"
"index.d.ts"
"simple.js"
"simple.d.ts"
"mcp.js"
"mcp.d.ts"
"http.js"
"http.d.ts"
"src/a2a.js"
"src/a2a.d.ts"
)
for file in "${REQUIRED_PACKED_FILES[@]}"; do
grep -F " ${file}" pack-dry-run.txt >/dev/null || {
echo "::error::npm pack output missing expected file: $file"
exit 1
}
done
working-directory: jacsnpm
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'
# NPM_TOKEN must be a granular access token with "Packages: Read and write"
# and "Bypass 2FA for automation" enabled (npm → Access Tokens → Generate New Token).
- name: Publish to npm
run: npm publish --access public --provenance
working-directory: jacsnpm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}