Skip to content

v0.3.5

v0.3.5 #7

Workflow file for this run

name: NPM Release
on:
release:
types: [published]
push:
branches:
- develop
paths:
- 'libCacheSim-node/**'
permissions:
contents: read
actions: read
env:
BUILD_TYPE: Release
jobs:
create-release:
if: github.event_name == 'release'
runs-on: ubuntu-latest
permissions:
contents: write # Needed for creating GitHub releases
outputs:
release_created: ${{ steps.release.outputs.release_created }}
version: ${{ steps.package.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Synchronize Node.js binding version
run: |
echo "Synchronizing Node.js binding version with main project..."
python3 scripts/sync_node_version.py
- name: Get package version
id: package
working-directory: libCacheSim-node
run: |
VERSION=$(node -p "require('./package.json').version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Check if release exists
id: check_release
run: |
VERSION="${{ steps.package.outputs.version }}"
if gh release view "v$VERSION" > /dev/null 2>&1; then
echo "Release v$VERSION already exists"
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "Release v$VERSION does not exist"
echo "exists=false" >> $GITHUB_OUTPUT
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create GitHub Release
id: release
if: steps.check_release.outputs.exists == 'false'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.package.outputs.version }}
release_name: Release v${{ steps.package.outputs.version }}
body: |
Release v${{ steps.package.outputs.version }}
## Installation
```bash
npm install libcachesim-node
```
## Supported Platforms
- Linux x64
Pre-compiled binaries are automatically downloaded during installation.
draft: false
prerelease: false
build-and-publish:
if: github.event_name == 'release'
needs: create-release
runs-on: ubuntu-latest
permissions:
contents: write # Needed for uploading prebuilt binaries to releases
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Synchronize Node.js binding version
run: |
echo "Synchronizing Node.js binding version with main project..."
python3 scripts/sync_node_version.py
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake ninja-build libglib2.0-dev libzstd-dev
- name: Build libCacheSim
run: |
echo "Building libCacheSim for Linux x64..."
mkdir -p _build
cd _build
cmake -G Ninja -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} .. -DCMAKE_VERBOSE_MAKEFILE=ON
echo "Starting build..."
ninja -v
- name: Prepare vendored library
run: |
mkdir -p libCacheSim-node/vendor/include
cp _build/liblibCacheSim.a libCacheSim-node/vendor/
cp -r libCacheSim/include/* libCacheSim-node/vendor/include/
- name: Install Node.js dependencies
working-directory: libCacheSim-node
run: npm install
- name: Build and upload prebuilt binary
working-directory: libCacheSim-node
run: |
echo "Building Node.js addon for Linux x64..."
echo "Node.js version: $(node --version)"
echo "NPM version: $(npm --version)"
ls -la ../
ls -la ../_build/
CFLAGS=-fPIC CXXFLAGS=-fPIC npx prebuild --upload-all --verbose
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Test binary
working-directory: libCacheSim-node
run: |
echo "Testing binary load for Linux x64..."
ls -la
ls -la prebuilds/ || echo "No prebuilds directory found"
node -e "console.log('Testing binary load...'); try { require('./index.js'); console.log('Binary loaded successfully!'); } catch(e) { console.error('Failed to load binary:', e); process.exit(1); }"
publish-npm:
if: github.event_name == 'release'
needs: build-and-publish
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Synchronize Node.js binding version
run: |
echo "Synchronizing Node.js binding version with main project..."
python3 scripts/sync_node_version.py
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake ninja-build libglib2.0-dev libzstd-dev
- name: Build libCacheSim
run: |
mkdir -p _build
cd _build
cmake -G Ninja -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} ..
ninja
- name: Prepare vendored library
run: |
mkdir -p libCacheSim-node/vendor/include
cp _build/liblibCacheSim.a libCacheSim-node/vendor/
cp -r libCacheSim/include/* libCacheSim-node/vendor/include/
- name: Publish to NPM
working-directory: libCacheSim-node
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}