Skip to content

Build release artifacts #13

Build release artifacts

Build release artifacts #13

Workflow file for this run

name: Build release artifacts
on:
workflow_dispatch:
inputs:
upload-artifacts:
type: string
default: 'NO'
artifacts-retention-days:
type: number
default: 1
publish:
type: string
default: 'NO'
target:
type: string
description: 'The target package to build'
default: '*'
workflow_call:
inputs:
upload-artifacts:
type: string
default: 'YES'
artifacts-retention-days:
type: number
default: 3
publish:
type: string
default: 'NO'
secrets:
NPM_TOKEN:
required: true
env:
HEXAGON_SDK_VERSION: '6.4.0.2'
OPENCL_VERSION: '2025.07.22'
jobs:
build:
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
strategy:
matrix:
include:
# Linux x86_64 default
- os: ubuntu-22.04
arch: x86_64
container: ''
target: default
package: node-whisper-linux-x64
# Linux x86_64 CUDA
- os: ubuntu-22.04
arch: x86_64
container: nvidia/cuda:12.6.2-devel-ubuntu22.04
target: cuda
package: node-whisper-linux-x64-cuda
need-fix-git: 'true'
# Linux x86_64 Vulkan
- os: ubuntu-22.04
arch: x86_64
target: vulkan
package: node-whisper-linux-x64-vulkan
# Linux arm64 default
- os: ubuntu-22.04-arm
arch: arm64
target: default
package: node-whisper-linux-arm64
# Linux arm64 CUDA
- os: ubuntu-22.04-arm
arch: arm64
container: nvidia/cuda:12.6.2-devel-ubuntu22.04
target: cuda
package: node-whisper-linux-arm64-cuda
need-fix-git: 'true'
# Linux arm64 Vulkan
- os: ubuntu-22.04-arm
arch: arm64
target: vulkan
package: node-whisper-linux-arm64-vulkan
# macOS x64
- os: macos-13
arch: x64
target: default
package: node-whisper-darwin-x64
# macOS arm64
- os: macos-14
arch: arm64
target: default
package: node-whisper-darwin-arm64
# Windows x64 default
- os: windows-latest
arch: x64
target: default
package: node-whisper-win32-x64
toolchain: clang-cl
# Windows x64 CUDA
- os: windows-latest
arch: x64
target: cuda
package: node-whisper-win32-x64-cuda
toolchain: cl
cuda-version: '12.9.1.576'
# Windows x64 Vulkan
- os: windows-latest
arch: x64
target: vulkan
package: node-whisper-win32-x64-vulkan
toolchain: mingw-clang
# Windows arm64 default
- os: windows-latest
arch: arm64
target: default
package: node-whisper-win32-arm64
toolchain: mingw-clang
# Windows arm64 Vulkan
- os: windows-latest
arch: arm64
target: vulkan
package: node-whisper-win32-arm64-vulkan
toolchain: mingw-clang
# Linux arm64 Snapdragon (cross-compiled on x86_64)
- os: ubuntu-24.04
arch: arm64
target: snapdragon
package: node-whisper-linux-arm64-snapdragon
cross-compile: true
# TODO: uncomment this when Windows arm64 Snapdragon is supported
# # Windows arm64 Snapdragon
# - os: windows-latest
# arch: arm64
# target: snapdragon
# package: node-whisper-win32-arm64-snapdragon
# toolchain: mingw-clang
steps:
- name: Run this job?
id: run
env:
TRIGGER_TARGET: node-whisper-${{ github.event.inputs.target || '*' }}
TARGET: ${{ matrix.package }}
shell: bash
run: |
if [[ "$TARGET" == $TRIGGER_TARGET ]]; then
echo "should-run=true" >> $GITHUB_OUTPUT
else
echo "should-run=false" >> $GITHUB_OUTPUT
fi
- name: Upgrade git
if: steps.run.outputs.should-run == 'true' && matrix.need-fix-git == 'true'
run: apt-get update && apt-get install -y git
- uses: actions/checkout@v4
if: steps.run.outputs.should-run == 'true'
with:
submodules: "true"
- name: ccache cache
if: steps.run.outputs.should-run == 'true'
uses: actions/cache@v4
with:
path: .ccache
key: ${{ matrix.package }}-ccache
- name: set ccache path
if: steps.run.outputs.should-run == 'true'
run: |
echo "CCACHE_BASEDIR=${{ github.workspace }}/.ccache" >> $GITHUB_ENV
- uses: actions/setup-node@v4
if: steps.run.outputs.should-run == 'true'
with:
node-version: 20
- name: Install CUDA
if: steps.run.outputs.should-run == 'true' && matrix.target == 'cuda' && matrix.cuda-version
uses: ./.github/actions/setup-cuda
with:
version: ${{ matrix.cuda-version }}
cache: true
- name: Install dependencies
if: steps.run.outputs.should-run == 'true'
run: npm install --omit=optional
- name: Install Vulkan SDK
if: steps.run.outputs.should-run == 'true' && matrix.target == 'vulkan'
uses: jakoch/install-vulkan-sdk-action@v1.2.4
with:
vulkan_version: '1.4.313.0'
install_runtime: true
optional_components: com.lunarg.vulkan.arm64
cache: true
stripdown: true
- name: Prepare & build (Linux)
if: steps.run.outputs.should-run == 'true' && runner.os == 'Linux'
run: |
bash ./scripts/prepare-linux.sh -a ${{ matrix.arch }} -t ${{ matrix.target }}
bash ./scripts/build-linux.sh -a ${{ matrix.arch }} -t ${{ matrix.target }}
- name: Prepare & build (macOS)
if: steps.run.outputs.should-run == 'true' && runner.os == 'macOS'
run: |
bash ./scripts/build-macos.sh
- name: Prepare & build (Windows)
if: steps.run.outputs.should-run == 'true' && runner.os == 'Windows'
shell: pwsh
run: |
$ErrorActionPreference='Stop'
. ./scripts/prepare-windows.ps1 -arch ${{ matrix.arch }} -target ${{ matrix.target }} -toolchain ${{ matrix.toolchain }}
pwsh ./scripts/build-windows.ps1 -arch ${{ matrix.arch }} -target ${{ matrix.target }} -toolchain ${{ matrix.toolchain }}
- name: Upload build artifacts
if: steps.run.outputs.should-run == 'true' && (github.event.inputs.upload-artifacts == 'YES' || inputs.upload-artifacts == 'YES')
uses: actions/upload-artifact@v4
with:
name: bin-${{ matrix.package }}
path: |
build
packages/${{ matrix.package }}
retention-days: ${{ inputs.artifacts-retention-days }}
- name: Publish to NPM
if: steps.run.outputs.should-run == 'true' && (github.event.inputs.publish == 'YES' || inputs.publish == 'YES')
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm run publish-if-need packages/${{ matrix.package }}