Skip to content

Fix published entrypoint and add ATTW package test #3

Fix published entrypoint and add ATTW package test

Fix published entrypoint and add ATTW package test #3

Workflow file for this run

name: Publish
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
dry_run:
description: "Run npm publish in dry-run mode"
required: false
default: true
type: boolean
jobs:
build-native:
env:
RUSTC_WRAPPER: sccache
SCCACHE_GHA_ENABLED: "true"
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
target: x86_64-apple-darwin
cross_compile: false
- os: macos-latest
target: aarch64-apple-darwin
cross_compile: false
- os: windows-latest
target: x86_64-pc-windows-msvc
cross_compile: false
- os: windows-latest
target: aarch64-pc-windows-msvc
cross_compile: false
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
cross_compile: false
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
cross_compile: true
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
cross_compile: false
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-musl
cross_compile: true
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v6
with:
node-version: 20
cache: pnpm
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install sccache
uses: mozilla-actions/sccache-action@v0.0.9
- name: Cache Rust build
uses: Swatinem/rust-cache@v2
with:
shared-key: native-${{ matrix.target }}
- name: Install dependencies
run: pnpm install
- name: Install Zig
if: matrix.cross_compile
uses: goto-bus-stop/setup-zig@v2
- name: Build native target
if: ${{ !matrix.cross_compile }}
run: pnpm exec napi build --platform --release --target ${{ matrix.target }}
- name: Build native target (cross)
if: matrix.cross_compile
run: pnpm exec napi build --platform --release --cross-compile --target ${{ matrix.target }}
- name: Upload native artifact
uses: actions/upload-artifact@v4
with:
name: bindings-${{ matrix.target }}
path: slatedb-node.*.node
if-no-files-found: error
- name: Show sccache stats
if: always()
run: sccache --show-stats
publish:
runs-on: ubuntu-latest
needs:
- build-native
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v6
with:
node-version: 20
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Build TypeScript API
run: pnpm run build:ts
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create platform package dirs
run: pnpm run create-npm-dirs
- name: Move native binaries into platform packages
run: pnpm run artifacts
- name: Publish package(s)
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm config set provenance true
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ inputs.dry_run }}" = "true" ]; then
npm publish --access public --dry-run
else
npm publish --access public
fi