Skip to content

Publish tdl

Publish tdl #57

Workflow file for this run

name: Publish tdl
# This workflow can be executed using a command like this:
# gh workflow run publish-tdl.yml --ref develop -f npm-tag=latest
on:
workflow_dispatch:
inputs:
npm-tag:
description: 'npm tag (e.g. latest, beta), required to publish'
type: string
required: false
jobs:
build-and-test:
name: Build the node addon on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-13, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: npm
- uses: goto-bus-stop/setup-zig@v2
with:
version: '0.13.0'
if: runner.os == 'Linux'
- name: Install dependencies
run: npm install
- name: Clean old binaries
run: npm run clean -w tdl
- name: Prebuildify (Linux via zig)
if: runner.os == 'Linux'
run: |
CC="zig cc -target x86_64-linux-gnu.2.22" CXX="zig c++ -target x86_64-linux-gnu.2.22 -s" \
npm exec -w tdl -- prebuildify --napi -t 18.20.5 --arch x64 --tag-libc --strip
CC="zig cc -target aarch64-linux-gnu.2.22" CXX="zig c++ -target aarch64-linux-gnu.2.22 -s" \
npm exec -w tdl -- prebuildify --napi -t 18.20.5 --arch arm64 --armv 8 --tag-armv --tag-libc
ldd packages/tdl/prebuilds/*-x64/*.node
file packages/tdl/prebuilds/*/*.node
du -hsc packages/tdl/prebuilds/*/*.node
- name: Prebuildify (macOS x86_64 and Windows x86_64)
if: runner.os != 'Linux'
run: npm exec -w tdl -- prebuildify --napi -t 18.20.5 --arch x64 --strip"
- name: "Prebuildify: Crosscompile to arm64 Apple Silicon"
if: runner.os == 'macOS'
run: |
prebuildify --napi -t 18.20.5 --arch arm64 --strip
file packages/tdl/prebuilds/*/*.node
du -hsc packages/tdl/prebuilds/*/*.node
- name: Run tests (unit tests + integration tests)
run: npm run test:all
- uses: actions/upload-artifact@v4
with:
name: tdl-prebuilds-${{ matrix.os }}
path: packages/tdl/prebuilds
publish:
name: 'Publish to npm'
needs: [build-and-test]
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: npm
# registry-url is mandatory here
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm install
- uses: actions/download-artifact@v4
with:
pattern: tdl-prebuilds-*
path: packages/tdl/prebuilds
merge-multiple: true
- run: tree packages/tdl/prebuilds
- name: Ensure prebuilts exist
run: (( $(ls packages/tdl/prebuilds | wc -l) > 3 ))
- name: Tests (excluding integration tests)
run: npm test
- name: Publish
if: "${{ inputs.npm-tag != '' }}"
run: npm publish --provenance --access public --tag ${{ inputs.npm-tag }} -w tdl
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}