Skip to content

ci: Fix builds

ci: Fix builds #42

Workflow file for this run

name: CI
env:
DEBUG: napi:*
MACOSX_DEPLOYMENT_TARGET: '10.13'
RUST_BACKTRACE: 1
on:
push:
branches:
- main
tags:
- 'v*.*.*'
pull_request:
jobs:
build:
name: Build - ${{ matrix.target }}
if: "!contains(github.event.head_commit.message, 'skip ci')"
strategy:
fail-fast: false
matrix:
target: [aarch64-apple-darwin, x86_64-unknown-linux-gnu]
include:
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18
cache: npm
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Cache NPM dependencies
uses: actions/cache@v4
with:
path: node_modules
key: npm-cache-${{ matrix.target }}-node@18-${{ hashFiles('package-lock.json') }}
- name: Cache Rust dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: rust-cache-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
- name: Install dependencies
run: npm install
shell: bash
- name: Build
run: npx nx build:native -- --platform ${{ matrix.target }}
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bindings-${{ matrix.target }}
path: |
**/*.node
!node_modules/**/*.node
!target/**/*.node
if-no-files-found: error
retention-days: 1
test:
name: Test ${{ matrix.platform.name }} - node@${{ matrix.node }}
needs:
- build
strategy:
fail-fast: false
matrix:
node:
- 18
platform:
- name: macOS ARM64
runner: macos-latest
target: aarch64-apple-darwin
runs-on: ${{ matrix.platform.runner }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
check-latest: true
cache: npm
- name: 💾 Cache dependencies
uses: actions/cache@v4
with:
path: |
node_modules
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
.cargo-cache
target/
key: >
deps-${{ matrix.platform.target }}-${{ matrix.node }}-
${{ contains(matrix.platform.target, 'aarch64') && 'npm-install' || 'npm-ci' }}-
${{ hashFiles('package-lock.json', '**/Cargo.lock') }}
- name: Install dependencies
uses: actions/download-artifact@v4
with:
name: bindings-${{ matrix.target }}
- name: Install dependencies
run: npm install
- name: Test
run: npm test
dry-run-publish:
name: Dry Run Publish
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
needs:
- build
- test
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18
check-latest: true
cache: npm
- name: Cache NPM dependencies
uses: actions/cache@v4
with:
path: node_modules
key: npm-cache-ubuntu-latest-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
run: npm ci
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: bindings-aarch64-apple-darwin
- name: Move artifacts
run: |
mkdir -p dist
find . -type f -name 'cel-typescript.*.node' -exec mv {} . \;
- name: List files
run: |
echo "Root directory:"
ls -la
echo "\nNode files:"
find . -maxdepth 1 -name '*.node'
shell: bash
- name: Link local package
run: npm link
- name: Build TypeScript
run: npm run build:ts
- name: Verify package contents
run: |
echo "Package contents:"
npm pack --dry-run
publish:
name: ${{ github.event_name == 'pull_request' && '🔍 Publish (Dry Run)' || '📦 Publish' }}
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'pull_request'
needs:
- build
- test
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Debug - List submodules
run: |
git submodule status
ls -la
ls -la cel-rust/
ls -la cel-rust/interpreter/
shell: bash
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18
check-latest: true
cache: npm
- name: Cache NPM dependencies
uses: actions/cache@v4
with:
path: node_modules
key: npm-cache-ubuntu-latest-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
run: npm ci
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: bindings-aarch64-apple-darwin
- name: Move artifacts
run: |
mkdir -p dist
find . -type f -name 'cel-typescript.*.node' -exec mv {} . \;
- name: List files
run: |
echo "Root directory:"
ls -la
echo "\nNode files:"
find . -maxdepth 1 -name '*.node'
shell: bash
- name: Link local package
run: npm link
- name: Build TypeScript
run: npm run build:ts
- name: Verify package contents
run: |
echo "Package contents:"
npm pack --dry-run
- name: ⚙️ Configure npm
if: github.event_name != 'pull_request'
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- name: 🚀 Publish
if: github.event_name != 'pull_request' && env.NPM_TOKEN != ''
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public --provenance
- name: 🔍 Dry Run Publish
if: github.event_name == 'pull_request'
run: npm publish --dry-run