Skip to content

Merge pull request #28 from raphaelmansuy/bench/ooda-score-improvemen… #11

Merge pull request #28 from raphaelmansuy/bench/ooda-score-improvemen…

Merge pull request #28 from raphaelmansuy/bench/ooda-score-improvemen… #11

Workflow file for this run

name: Release — Node.js (npm)
on:
push:
tags: ['v[0-9]+.[0-9]+.[0-9]+']
workflow_dispatch:
inputs:
tag_name:
description: 'Tag name to publish (e.g. v0.2.1) — used for version sync'
required: true
default: 'v0.2.1'
permissions:
contents: read
jobs:
build-native:
name: Build .node — ${{ matrix.target }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
runner: ubuntu-latest
node-platform: linux-x64-gnu
- target: aarch64-unknown-linux-gnu
runner: ubuntu-latest
node-platform: linux-arm64-gnu
use-zigbuild: true
- target: x86_64-apple-darwin
runner: macos-latest
node-platform: darwin-x64
- target: aarch64-apple-darwin
runner: macos-14
node-platform: darwin-arm64
- target: x86_64-pc-windows-msvc
runner: windows-latest
node-platform: win32-x64-msvc
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with: { targets: '${{ matrix.target }}' }
- uses: Swatinem/rust-cache@v2
- name: Install zig + cargo-zigbuild (for aarch64 Linux cross)
if: matrix.use-zigbuild
run: |
pip install ziglang
cargo install cargo-zigbuild --locked
- name: Build Rust binding
run: |
if [[ "${{ matrix.use-zigbuild }}" == "true" ]]; then
cargo zigbuild --release --target ${{ matrix.target }}.2.17 -p edgeparse-node
else
cargo build --release --target ${{ matrix.target }} -p edgeparse-node
fi
shell: bash
- name: Rename .node artifact
shell: bash
run: |
TARGET="${{ matrix.target }}"
if [[ "$TARGET" == *"windows"* ]]; then
SRC="target/${TARGET}/release/edgeparse_node.dll"
elif [[ "$TARGET" == *"apple"* ]]; then
SRC="target/${TARGET}/release/libedgeparse_node.dylib"
else
SRC="target/${TARGET}/release/libedgeparse_node.so"
fi
DEST="sdks/node/npm/${{ matrix.node-platform }}/edgeparse-node.${{ matrix.node-platform }}.node"
mkdir -p "sdks/node/npm/${{ matrix.node-platform }}"
cp "$SRC" "$DEST"
- uses: actions/upload-artifact@v4
with:
name: node-${{ matrix.node-platform }}
path: sdks/node/npm/${{ matrix.node-platform }}/
publish-npm:
name: Publish to npm
needs: build-native
runs-on: ubuntu-latest
environment: npm
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- uses: actions/download-artifact@v4
with:
merge-multiple: true
path: sdks/node/npm/
- name: Sync version
env:
INPUT_TAG_NAME: ${{ inputs.tag_name }}
run: |
node -e "
const fs = require('fs');
const refName = process.env.INPUT_TAG_NAME || process.env.GITHUB_REF_NAME;
const version = refName.replace(/^v/, '');
const dirs = [
'sdks/node',
...fs.readdirSync('sdks/node/npm').map(d => \`sdks/node/npm/\${d}\`)
];
dirs.forEach(dir => {
const p = \`\${dir}/package.json\`;
if (fs.existsSync(p)) {
const pkg = JSON.parse(fs.readFileSync(p, 'utf8'));
// Update optionalDependencies versions
Object.keys(pkg.optionalDependencies || {}).forEach(k => {
pkg.optionalDependencies[k] = version;
});
pkg.version = version;
fs.writeFileSync(p, JSON.stringify(pkg, null, 2) + '\n');
}
});
console.log('Version synced to: ' + version);
"
- run: |
cd sdks/node
npm ci
npm run build:ts
- name: Publish platform packages
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
for dir in sdks/node/npm/*/; do
OUTPUT=$((cd "$dir" && npm publish --access public) 2>&1) && echo "$OUTPUT" || {
echo "$OUTPUT"
if echo "$OUTPUT" | grep -Eq "cannot publish over the previously published versions|You cannot publish over the previously published version"; then
echo "::warning::Package already published for $dir — skipping."
else
exit 1
fi
}
done
- name: Publish edgeparse (main package)
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
cd sdks/node
OUTPUT=$(npm publish --access public 2>&1) && echo "$OUTPUT" || {
echo "$OUTPUT"
if echo "$OUTPUT" | grep -Eq "cannot publish over the previously published versions|You cannot publish over the previously published version"; then
echo "edgeparse already published at this version — skipping."
else
exit 1
fi
}