name: Build on: push: branches: - master - beta pull_request: workflow_dispatch: jobs: build: name: Build runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - uses: actions/setup-node@v6 with: node-version: "22" package-manager-cache: false - name: Install modules env: ELECTRON_SKIP_BINARY_DOWNLOAD: "1" run: npm ci - name: Build run: npm run build - name: Download latest llama.cpp release env: CI: true GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: node ./dist/cli/cli.js source download --release latest --skipBuild --noBundle --noUsageExample --updateBinariesReleaseMetadataAndSaveGitBundle - name: Upload build artifact uses: actions/upload-artifact@v7 with: include-hidden-files: true name: "build" path: "dist" - name: Upload packed templates artifact uses: actions/upload-artifact@v7 with: include-hidden-files: true name: "build-templates" path: "templates/packed" - name: Upload llama.cpp artifact uses: actions/upload-artifact@v7 with: include-hidden-files: true name: "llama.cpp" path: | llama/binariesGithubRelease.json llama/llama.cpp.info.json llama/llama.cpp llama/gitRelease.bundle build-binaries: name: Build binaries - ${{ matrix.config.name }} needs: - build runs-on: ${{ matrix.config.os }} strategy: fail-fast: false matrix: config: - name: "Windows (1)" os: windows-2022 artifact: "win-1" - name: "Windows (2)" os: windows-2022 artifact: "win-2" - name: "Ubuntu (1)" os: ubuntu-22.04 artifact: "linux-1" - name: "Ubuntu (2)" os: ubuntu-22.04 artifact: "linux-2" - name: "Ubuntu (arm64)" os: ubuntu-22.04-arm artifact: "linux-arm64" - name: "macOS x64" os: macos-15-intel artifact: "mac-x64" - name: "macOS arm64" os: macos-26 artifact: "mac-arm64" - name: "Ubuntu riscv64" os: ubuntu-24.04-riscv artifact: "linux-riscv64" steps: - uses: actions/checkout@v6 - uses: actions/setup-node@v6 if: matrix.config.artifact != 'linux-riscv64' with: node-version: "22" package-manager-cache: false - name: Install Node.js (riscv64 unofficial build) if: matrix.config.artifact == 'linux-riscv64' run: | set -e need=24.10.0 if command -v node >/dev/null 2>&1; then cur="$(node -p 'process.versions.node')" if [ "$(printf '%s\n%s\n' "$need" "$cur" | sort -V | head -1)" = "$need" ]; then echo "Using preinstalled Node.js v$cur at $(command -v node)" exit 0 fi echo "Preinstalled Node.js v$cur is older than $need; installing unofficial build" fi NODE_VER=v24.16.0 curl -fsSL -o /tmp/node.tar.xz "https://unofficial-builds.nodejs.org/download/release/${NODE_VER}/node-${NODE_VER}-linux-riscv64.tar.xz" mkdir -p "$HOME/node" tar -xJf /tmp/node.tar.xz -C "$HOME/node" --strip-components=1 echo "$HOME/node/bin" >> "$GITHUB_PATH" "$HOME/node/bin/node" --version - name: Download build artifact uses: actions/download-artifact@v8 with: name: build path: dist - name: Download llama.cpp artifact uses: actions/download-artifact@v8 with: name: llama.cpp path: llama - name: Install dependencies on Windows if: startsWith(matrix.config.os, 'windows') run: | choco install cmake.install --version=4.2.1 choco install cmake --version=4.2.1 choco install ninja - name: Install dependencies on Ubuntu (1) if: matrix.config.name == 'Ubuntu (1)' run: | sudo apt-get update sudo apt-get install ninja-build libtbb-dev wget -c https://github.com/Kitware/CMake/releases/download/v4.2.1/cmake-4.2.1-linux-x86_64.tar.gz sudo tar --strip-components=1 -C /usr/local -xzf cmake-4.2.1-linux-x86_64.tar.gz rm -f ./cmake-4.2.1-linux-x86_64.tar.gz cmake --version - name: Install dependencies on Ubuntu (2) if: matrix.config.name == 'Ubuntu (2)' run: | sudo apt-get update sudo apt-get install ninja-build libtbb-dev wget -c https://github.com/Kitware/CMake/releases/download/v4.2.1/cmake-4.2.1-linux-x86_64.tar.gz sudo tar --strip-components=1 -C /usr/local -xzf cmake-4.2.1-linux-x86_64.tar.gz rm -f ./cmake-4.2.1-linux-x86_64.tar.gz cmake --version - name: Install dependencies on Ubuntu (arm64) if: matrix.config.name == 'Ubuntu (arm64)' env: LLVM_VERSION: 21 run: | wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh sudo ./llvm.sh "${LLVM_VERSION}" sudo apt-get update sudo apt-get install -y ninja-build libtbb-dev "clang-${LLVM_VERSION}" "lld-${LLVM_VERSION}" "llvm-${LLVM_VERSION}" g++-arm-linux-gnueabihf gcc-arm-linux-gnueabihf sudo update-alternatives --install /usr/bin/cc cc "/usr/bin/clang-${LLVM_VERSION}" 100 sudo update-alternatives --install /usr/bin/c++ c++ "/usr/bin/clang++-${LLVM_VERSION}" 100 sudo update-alternatives --install /usr/bin/gcc gcc "/usr/bin/clang-${LLVM_VERSION}" 100 sudo update-alternatives --install /usr/bin/g++ g++ "/usr/bin/clang++-${LLVM_VERSION}" 100 wget -c https://github.com/Kitware/CMake/releases/download/v4.2.1/cmake-4.2.1-linux-aarch64.tar.gz sudo tar --strip-components=1 -C /usr/local -xzf cmake-4.2.1-linux-aarch64.tar.gz rm -f ./cmake-4.2.1-linux-aarch64.tar.gz cc --version c++ --version gcc --version g++ --version which arm-linux-gnueabihf-gcc which arm-linux-gnueabihf-g++ cmake --version # llama.cpp's ggml-cpu uses the RVV _Float16 (zvfh) vector intrinsics, # which only exist in GCC 14+. The runner defaults to GCC 13, so make # gcc-14/g++-14 the default compilers (same as upstream build-riscv). - name: Install dependencies on Ubuntu riscv64 if: matrix.config.name == 'Ubuntu riscv64' run: | sudo apt-get update sudo apt-get install -y cmake build-essential ninja-build libtbb-dev gcc-14 g++-14 retry sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100 sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 100 cmake --version gcc --version - name: Install Cuda 13.1 on Windows (1) if: matrix.config.name == 'Windows (1)' uses: Jimver/cuda-toolkit@v0.2.30 with: cuda: '13.1.0' method: 'network' use-local-cache: false - name: Install Cuda 12.4 on Windows (2) if: matrix.config.name == 'Windows (2)' uses: Jimver/cuda-toolkit@v0.2.15 with: cuda: '12.4.0' method: 'network' sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "thrust", "visual_studio_integration"]' use-local-cache: false - name: Install Cuda 13.1 on Ubuntu (1) if: matrix.config.name == 'Ubuntu (1)' uses: Jimver/cuda-toolkit@v0.2.30 with: cuda: '13.1.0' method: 'network' - name: Install Cuda 12.4 on Ubuntu (2) if: matrix.config.name == 'Ubuntu (2)' uses: Jimver/cuda-toolkit@v0.2.15 with: cuda: '12.4.0' method: 'network' - name: Install Vulkan SDK on Windows (1) if: matrix.config.name == 'Windows (1)' shell: powershell env: VULKAN_VERSION: 1.4.313.2 run: | # $env:VULKAN_VERSION = & curl.exe -fsSL https://vulkan.lunarg.com/sdk/latest/linux.txt # Write-Host "Downloading Vulkan SDK version $env:VULKAN_VERSION" curl.exe -o $env:RUNNER_TEMP/VulkanSDK-Installer.exe -L "https://sdk.lunarg.com/sdk/download/${env:VULKAN_VERSION}/windows/vulkansdk-windows-X64-${env:VULKAN_VERSION}.exe" & "$env:RUNNER_TEMP\VulkanSDK-Installer.exe" --accept-licenses --default-answer --confirm-command install Add-Content $env:GITHUB_ENV "VULKAN_SDK=C:\VulkanSDK\${env:VULKAN_VERSION}" Add-Content $env:GITHUB_PATH "C:\VulkanSDK\${env:VULKAN_VERSION}\bin" - name: Install Vulkan SDK on Ubuntu if: matrix.config.name == 'Ubuntu (1)' env: VULKAN_VERSION: 1.4.341.1 run: | # export VULKAN_VERSION="$(curl -fsSL https://vulkan.lunarg.com/sdk/latest/linux.txt)" # echo "Downloading Vulkan SDK version ${VULKAN_VERSION}" sudo apt-get update sudo apt-get install xz-utils curl --no-progress-meter "https://sdk.lunarg.com/sdk/download/${VULKAN_VERSION}/linux/vulkan_sdk.tar.xz" -o "/opt/vulkan-sdk.tar.xz" mkdir -p "/opt/vulkan-sdk" tar -Jxf "/opt/vulkan-sdk.tar.xz" --strip-components=1 -C "/opt/vulkan-sdk" rm -f "/opt/vulkan-sdk.tar.xz" echo "VULKAN_SDK=/opt/vulkan-sdk/x86_64" >> $GITHUB_ENV echo "/opt/vulkan-sdk/x86_64/bin" >> $GITHUB_PATH - name: Install dependencies on macOS if: matrix.config.name == 'macOS x64' || matrix.config.name == 'macOS arm64' run: | brew install cmake ninja alias make=cmake cmake --version uname -mprs - name: Setup & Build id: build shell: bash timeout-minutes: 300 env: ARTIFACT_NAME: ${{ matrix.config.artifact }} ELECTRON_SKIP_BINARY_DOWNLOAD: "1" run: | if [ "$ARTIFACT_NAME" = "linux-riscv64" ]; then # The unofficial riscv64 Node runtime intermittently throws internal # TypeErrors during npm ci (e.g. "key.match is not a function") retry --times=3 npm ci else npm ci fi npx zx -y <<'EOF' async function getLatestNodeVersions(maxDate) { const res = await fetch("https://nodejs.org/dist/index.json"); const data = await res.json(); const versions = new Map(); let latestVersion = null; for (const version of data) { const majorVersion = Number(version.version.split(".")[0].slice("v".length)); const versionDate = new Date(version.date); if (maxDate != null && versionDate.getTime() > maxDate) continue; if (!versions.has(majorVersion)) { versions.set(majorVersion, version.version); } if (latestVersion === null || majorVersion > latestVersion) { latestVersion = majorVersion; } } return {versions, latestVersion}; } const {versions: latestNodeVersions} = await getLatestNodeVersions(Date.now() - 1000 * 60 * 60 * 24 * 14); const nodeVersion = latestNodeVersions.get(20); const windowsOnArmNodeVersion = latestNodeVersions.get(20); if (nodeVersion == null || windowsOnArmNodeVersion == null) { throw new Error("Could not find node versions"); } $.verbose = true; await $`mkdir -p bins`; async function buildBinary(arch, flags = [], nodeTarget = nodeVersion) { console.log(`Building ${arch} for node ${nodeTarget} with flags`, flags); await $`node ./dist/cli/cli.js source build --ciMode --noUsageExample --arch ${arch} --nodeTarget ${nodeTarget} ${flags}`; } // build binaries if (process.env.ARTIFACT_NAME === "win-1") { await buildBinary("x64", ["--gpu", "false"]); await buildBinary("x64", ["--gpu", "cuda"]); await buildBinary("x64", ["--gpu", "vulkan"]); } else if (process.env.ARTIFACT_NAME === "win-2") { await buildBinary("arm64", ["--gpu", "false"], windowsOnArmNodeVersion); await buildBinary("x64", ["--gpu", "cuda"]); } else if (process.env.ARTIFACT_NAME === "linux-1") { await buildBinary("x64", ["--gpu", "false"]); await buildBinary("x64", ["--gpu", "cuda"]); await buildBinary("x64", ["--gpu", "vulkan"]); } else if (process.env.ARTIFACT_NAME === "linux-2") { await buildBinary("x64", ["--gpu", "cuda"]); } else if (process.env.ARTIFACT_NAME === "linux-arm64") { await buildBinary("arm64", ["--gpu", "false"]); await buildBinary("armv7l", ["--gpu", "false"]); } else if (process.env.ARTIFACT_NAME === "mac-x64") { await buildBinary("x64", ["--gpu", "false"]); } else if (process.env.ARTIFACT_NAME === "mac-arm64") { await buildBinary("arm64", ["--gpu", "metal"]); } else if (process.env.ARTIFACT_NAME === "linux-riscv64") { await buildBinary("riscv64", ["--gpu", "false"]); } // move binaries to bins const localBuildsDirectoryPath = path.join(process.cwd(), "llama", "localBuilds"); const llamaBinsDirectoryPath = path.join(process.cwd(), "bins"); for (const folderName of await fs.readdir(localBuildsDirectoryPath)) { await fs.move( path.join(localBuildsDirectoryPath, folderName, "Release"), path.join(llamaBinsDirectoryPath, folderName) ); } if (process.env.ARTIFACT_NAME === "win-2") { await fs.move( path.join(llamaBinsDirectoryPath, "win-x64-cuda"), path.join(llamaBinsDirectoryPath, "win-x64-cuda-2") ); if (!(await fs.pathExists(path.join(llamaBinsDirectoryPath, "win-x64-cuda-2", "ggml-cuda.dll")))) { throw new Error("ggml-cuda.dll not found in win-x64-cuda-2"); } } else if (process.env.ARTIFACT_NAME === "linux-2") { await fs.move( path.join(llamaBinsDirectoryPath, "linux-x64-cuda"), path.join(llamaBinsDirectoryPath, "linux-x64-cuda-2") ); if (!(await fs.pathExists(path.join(llamaBinsDirectoryPath, "linux-x64-cuda-2", "libggml-cuda.so")))) { throw new Error("libggml-cuda.so not found in linux-x64-cuda-2"); } } await $`echo "Built binaries:"`; await $`ls bins`; EOF # - name: Cache UPX # id: cache-upx # uses: actions/cache@v5 # with: # path: "upxInstallations/**" # key: cache-upx-${{ runner.os }}-${{ github.workflow }} # - name: Compress CUDA binary on Windows # if: matrix.config.name == 'Windows for x64' # shell: bash # env: # UPX_VERSION: 4.2.4 # run: | # mkdir -p upxInstallations # # if [ ! -f "./upxInstallations/upx-${UPX_VERSION}-win64.zip" ]; then # pushd upxInstallations # curl -OL "https://github.com/upx/upx/releases/download/v${UPX_VERSION}/upx-${UPX_VERSION}-win64.zip" # popd # fi # # mkdir -p upx # unzip -d ./upx "./upxInstallations/upx-${UPX_VERSION}-win64.zip" # mv "./upx/upx-${UPX_VERSION}-win64" ./upx/upx # # ./upx/upx/upx.exe --best ./bins/win-x64-cuda/Release/ggml.dll # - name: Compress CUDA binary on Ubuntu # if: matrix.config.name == 'Ubuntu' # env: # UPX_VERSION: 4.2.4 # run: | # mkdir -p upxInstallations # # if [ ! -f "./upxInstallations/upx-${UPX_VERSION}-amd64_linux.tar.xz" ]; then # pushd upxInstallations # curl -OL "https://github.com/upx/upx/releases/download/v${UPX_VERSION}/upx-${UPX_VERSION}-amd64_linux.tar.xz" # popd # fi # # mkdir -p upx # tar -xvf "./upxInstallations/upx-${UPX_VERSION}-amd64_linux.tar.xz" -C ./upx # mv "./upx/upx-${UPX_VERSION}-amd64_linux" ./upx/upx # # chmod +x ./bins/linux-x64-cuda/llama-addon.node # ./upx/upx/upx --best ./bins/linux-x64-cuda/libggml.so # chmod -x ./bins/linux-x64-cuda/llama-addon.node - name: Publish artifact uses: actions/upload-artifact@v7 with: include-hidden-files: true name: "bins-${{ matrix.config.artifact }}" path: "bins/*" resolve-next-release: name: Resolve next release if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/beta') runs-on: ubuntu-latest needs: - build permissions: pages: read id-token: write contents: read issues: read pull-requests: read discussions: read outputs: next-version: ${{ steps.save-next-version.outputs.next-version }} steps: - uses: actions/checkout@v6 - uses: actions/setup-node@v6 with: node-version: "22" package-manager-cache: false - name: Install modules env: ELECTRON_SKIP_BINARY_DOWNLOAD: "1" run: npm ci - name: Download build artifact uses: actions/download-artifact@v8 with: name: build path: dist - name: Download llama.cpp artifact uses: actions/download-artifact@v8 with: name: llama.cpp path: llama - name: Apply fix patch on semantic-release, to not check for push permission on dry run run: | git apply --ignore-whitespace ./scripts/patches/semantic-release+24.1.1.patch git apply --ignore-whitespace ./scripts/patches/@semantic-release+npm+13.1.2.patch - name: Resolve next release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: npx --no vite-node ./scripts/resolveNextReleaseVersion.ts --saveReleaseToFile ./semanticReleaseDryRunReleaseResult.json --saveVersionToFile ./resolvedNextVersion.txt - name: Save next version output id: save-next-version run: echo "next-version=$(cat ./resolvedNextVersion.txt)" >> $GITHUB_OUTPUT - name: Update job summary run: | if [ "$(cat ./resolvedNextVersion.txt)" == "false" ]; then echo "Next release version: \`N/A\`" >> $GITHUB_STEP_SUMMARY else echo "Next release version: \`$(cat ./resolvedNextVersion.txt)\`" >> $GITHUB_STEP_SUMMARY fi - name: Upload resolved release artifact uses: actions/upload-artifact@v7 with: include-hidden-files: true name: "resolved-next-release" path: "./semanticReleaseDryRunReleaseResult.json" standalone-tests: name: Standalone tests runs-on: ubuntu-22.04 needs: - build steps: - uses: actions/checkout@v6 - uses: actions/setup-node@v6 with: node-version: "22" package-manager-cache: false - name: Download build artifact uses: actions/download-artifact@v8 with: name: build path: dist - name: Download llama.cpp artifact uses: actions/download-artifact@v8 with: name: llama.cpp path: llama - name: Install dependencies on ubuntu run: | sudo apt-get update sudo apt-get install ninja-build cmake - name: Install modules env: ELECTRON_SKIP_BINARY_DOWNLOAD: "1" run: npm ci - name: Build binary run: node ./dist/cli/cli.js source build --noUsageExample - name: Run standalone tests run: npm run test:standalone model-dependent-tests: name: Model dependent tests runs-on: macos-15-intel env: NODE_LLAMA_CPP_GPU: false needs: - build steps: - uses: actions/checkout@v6 - uses: actions/setup-node@v6 with: node-version: "22" package-manager-cache: false - name: Download build artifact uses: actions/download-artifact@v8 with: name: build path: dist - name: Download llama.cpp artifact uses: actions/download-artifact@v8 with: name: llama.cpp path: llama # - name: Install dependencies on Ubuntu # run: | # sudo apt-get update # sudo apt-get install ninja-build cmake - name: Install dependencies on macOS run: | brew install cmake ninja alias make=cmake - name: Install modules env: ELECTRON_SKIP_BINARY_DOWNLOAD: "1" run: npm ci - name: Build binary run: node ./dist/cli/cli.js source build --noUsageExample - name: Inspect hardware run: node ./dist/cli/cli.js inspect gpu - name: Cache models id: cache-restore-test-models uses: actions/cache/restore@v5 with: path: "test/.models/**.gguf" key: cache-test-models-${{ runner.os }}-${{ github.workflow }} - name: Download models or ensure all models are downloaded id: download-all-test-models run: npm run dev:setup:downloadAllTestModels - name: Run model dependent tests env: NODE_OPTIONS: "--max-old-space-size=4096" run: npm run test:modelDependent - name: Save cached models id: cache-save-test-models if: steps.download-all-test-models.outcome == 'success' && always() uses: actions/cache/save@v5 with: path: "test/.models/**.gguf" key: cache-test-models-${{ runner.os }}-${{ github.workflow }} release: name: Release if: needs.resolve-next-release.outputs.next-version != '' && needs.resolve-next-release.outputs.next-version != 'false' runs-on: ubuntu-latest concurrency: release-${{ github.ref }} environment: name: npm url: ${{ steps.set-npm-url.outputs.npm-url }} permissions: id-token: write contents: write issues: write pull-requests: write discussions: write needs: - resolve-next-release - build - build-binaries outputs: package-version: ${{ steps.set-package-version.outputs.package-version }} steps: - uses: actions/checkout@v6 with: lfs: true - uses: actions/setup-node@v6 with: node-version: "22" package-manager-cache: false - name: Update npm run: npm install -g npm@latest - name: Install modules env: ELECTRON_SKIP_BINARY_DOWNLOAD: "1" run: npm ci - uses: actions/download-artifact@v8 with: path: artifacts - name: Move artifacts run: | mkdir -p bins mv artifacts/bins-*/* bins/ mv artifacts/build dist/ mkdir -p ./bins/win-x64-cuda/fallback mv ./bins/win-x64-cuda-2/ggml-cuda.dll ./bins/win-x64-cuda/fallback/ggml-cuda.dll rm -rf ./bins/win-x64-cuda-2 mkdir -p ./bins/linux-x64-cuda/fallback mv ./bins/linux-x64-cuda-2/libggml-cuda.so ./bins/linux-x64-cuda/fallback/libggml-cuda.so rm -rf ./bins/linux-x64-cuda-2 cp -r artifacts/llama.cpp/llama.cpp/grammars llama/grammars rm -f ./llama/binariesGithubRelease.json mv artifacts/llama.cpp/binariesGithubRelease.json ./llama/binariesGithubRelease.json rm -f ./llama/llama.cpp.info.json mv artifacts/llama.cpp/llama.cpp.info.json ./llama/llama.cpp.info.json rm -f ./llama/gitRelease.bundle mv artifacts/llama.cpp/gitRelease.bundle ./llama/gitRelease.bundle mv artifacts/build-templates templates/packed/ rm -f ./templates/package.json rm -f ./templates/package-lock.json echo "Built binaries:" ls bins - name: Move binaries to standalone prebuilt binary modules run: npx --no vite-node ./scripts/movePrebuiltBinariesToStandaloneModules.ts - name: Prepare standalone prebuilt binary modules run: npx --no vite-node ./scripts/prepareStandalonePrebuiltBinaryModules.ts - name: Add "postinstall" script to package.json run: npm run addPostinstallScript - name: Move semanticReleaseDryRunReleaseResult.json artifact run: mv artifacts/resolved-next-release/semanticReleaseDryRunReleaseResult.json ./semanticReleaseDryRunReleaseResult.json - name: Release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_RELEASE_REF: ${{ github.ref }} run: | export DRY_RUN_RESULT_FILE_PATH="$(pwd)/semanticReleaseDryRunReleaseResult.json" git apply --ignore-whitespace ./scripts/patches/@semantic-release+github+11.0.0.patch npx semantic-release - name: Set npm package url to GITHUB_OUTPUT id: set-npm-url run: | if [ -f .semanticRelease.npmPackage.deployedVersion.txt ]; then echo "npm-url=https://www.npmjs.com/package/node-llama-cpp/v/$(cat .semanticRelease.npmPackage.deployedVersion.txt)" >> $GITHUB_OUTPUT fi - name: Set package version to GITHUB_OUTPUT id: set-package-version run: | if [ -f .semanticRelease.npmPackage.deployedVersion.txt ]; then echo "package-version=$(cat .semanticRelease.npmPackage.deployedVersion.txt)" >> $GITHUB_OUTPUT fi - name: Prepare `create-node-llama-cpp` module if: steps.set-npm-url.outputs.npm-url != '' run: | export DEPLOYED_PACKAGE_VERSION=$(cat .semanticRelease.npmPackage.deployedVersion.txt) pushd packages/create-node-llama-cpp npm ci --ignore-scripts popd npx --no vite-node ./scripts/prepareCreateNodeLlamaCppModuleForPublish.ts --packageVersion "$DEPLOYED_PACKAGE_VERSION" pushd packages/create-node-llama-cpp npm run build - name: Release `create-node-llama-cpp` module if: steps.set-npm-url.outputs.npm-url != '' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_RELEASE_REF: ${{ github.ref }} run: | cd packages/create-node-llama-cpp if [ "$GH_RELEASE_REF" == "refs/heads/beta" ]; then npm publish --tag beta else npm publish fi auto-approve-documentation-website-deployment: name: Auto-approve documentation website deployment runs-on: ubuntu-latest continue-on-error: true needs: - release steps: - name: Approve documentation website deployment uses: activescott/automate-environment-deployment-approval@v2.1.0 with: github_token: ${{ secrets.AUTO_APPROVAL_GITHUB_TOKEN }} environment_allow_list: "Documentation website" actor_allow_list: giladgd build-electron-example: name: Build & release Electron app example - ${{ matrix.config.name }} needs: - release if: needs.release.outputs.package-version != '' runs-on: ${{ matrix.config.os }} permissions: contents: write strategy: fail-fast: false matrix: config: - name: "Windows" os: windows-2022 - name: "Ubuntu" os: ubuntu-22.04 - name: "macOS" os: macos-15-intel steps: - uses: actions/checkout@v6 with: lfs: true - uses: actions/setup-node@v6 with: node-version: "22" package-manager-cache: false - name: Install dependencies on Ubuntu if: matrix.config.name == 'Ubuntu' run: | sudo apt-get update sudo apt-get install libarchive-tools rpm sudo snap install snapcraft --classic - name: Install modules run: npm ci - name: Create Electron app project shell: bash env: DEPLOYED_PACKAGE_VERSION: ${{ needs.release.outputs.package-version }} NODE_LLAMA_CPP_SKIP_DOWNLOAD: true run: | npx --no vite-node ./scripts/scaffoldElectronExampleForCiBuild.ts --packageVersion "$DEPLOYED_PACKAGE_VERSION" --packageFolderPath ./electron-app-example npx --no vite-node ./scripts/waitForNpmRegistryToHaveModuleVersion.ts --packageVersion "$DEPLOYED_PACKAGE_VERSION" --additionalWait 60 --timeoutMinutes 10 cd electron-app-example npm install - name: Build electron app id: build shell: bash timeout-minutes: 480 run: | cd electron-app-example npm run build ls ./release - name: Upload artifacts uses: actions/upload-artifact@v7 with: include-hidden-files: true name: "electron-app-example-${{ matrix.config.name }}" path: "./electron-app-example/release" - name: Add builds to current release shell: bash env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} RELEASE_TAG: ${{ needs.release.outputs.package-version }} run: | shopt -s nullglob for file in ./electron-app-example/release/*.{dmg,zip,exe,appx,AppImage,snap,assert,deb,tar.gz}; do echo "Adding $file to release $RELEASE_TAG" gh release upload "v$RELEASE_TAG" "$file" done shopt -u nullglob update-documentation-website: name: Update documentation website if: | always() && github.event_name == 'push' && github.ref == 'refs/heads/master' && needs.build.result == 'success' && needs.resolve-next-release.result == 'success' && needs.resolve-next-release.outputs.next-version != '' && needs.resolve-next-release.outputs.next-version != 'false' && ( needs.release.result == 'skipped' || ( needs.release.result == 'success' && needs.release.outputs.package-version != '' ) ) runs-on: ubuntu-latest concurrency: update-documentation-website-${{ github.ref }} environment: name: Documentation website url: "https://node-llama-cpp.withcat.ai" permissions: pages: write id-token: write contents: read needs: - build - resolve-next-release - release # All steps are copied to `update-documentation-website-no-release` job # Can be replaced with YAML anchors when this will be supported by GitHub Actions: # https://github.com/actions/runner/issues/1182#issuecomment-2317953582 steps: - uses: actions/checkout@v6 with: lfs: true fetch-depth: 0 fetch-tags: true - uses: actions/setup-node@v6 with: node-version: "22" package-manager-cache: false - name: Install modules env: ELECTRON_SKIP_BINARY_DOWNLOAD: "1" run: npm ci - uses: actions/download-artifact@v8 with: path: artifacts - name: Move artifacts run: | mv artifacts/build dist/ cp -r artifacts/llama.cpp/llama.cpp llama/llama.cpp rm -f ./llama/binariesGithubRelease.json mv artifacts/llama.cpp/binariesGithubRelease.json ./llama/binariesGithubRelease.json rm -f ./llama/llama.cpp.info.json mv artifacts/llama.cpp/llama.cpp.info.json ./llama/llama.cpp.info.json - name: Resolve docs version env: RELEASE_VERSION: ${{ needs.release.outputs.package-version || needs.resolve-next-release.outputs.next-version }} run: | if [ "$RELEASE_VERSION" == "false" ]; then npx --no vite-node ./scripts/resolveLatestReleaseVersion.ts --saveVersionToFile ./docsVersion.txt else echo "$RELEASE_VERSION" > ./docsVersion.txt fi - name: Generate docs with updated version env: DOCS_URL_BASE: "/" run: | export DOCS_PACKAGE_VERSION="$(cat ./docsVersion.txt)" echo "Package version: $DOCS_PACKAGE_VERSION" npm run docs:build - name: Upload docs to GitHub Pages uses: actions/upload-pages-artifact@v5 with: name: pages-docs path: docs-site - name: Deploy docs to GitHub Pages uses: actions/deploy-pages@v5 with: artifact_name: pages-docs - name: Update feed run: | curl -X POST "https://pubsubhubbub.appspot.com/" -H "Content-Type: application/x-www-form-urlencoded" --data-urlencode "hub.mode=publish" --data-urlencode "hub.url=https://node-llama-cpp.withcat.ai/blog/feed.atom" update-documentation-website-no-release: name: Update documentation website - no version release if: | always() && github.event_name == 'push' && github.ref == 'refs/heads/master' && needs.build.result == 'success' && needs.resolve-next-release.result == 'success' && needs.resolve-next-release.outputs.next-version == 'false' runs-on: ubuntu-latest concurrency: update-documentation-website-${{ github.ref }} environment: name: Documentation website url: "https://node-llama-cpp.withcat.ai" permissions: pages: write id-token: write contents: read needs: - build - resolve-next-release # All steps are copied to `update-documentation-website` job # Can be replaced with YAML anchors when this will be supported by GitHub Actions: # https://github.com/actions/runner/issues/1182#issuecomment-2317953582 steps: - uses: actions/checkout@v6 with: lfs: true fetch-depth: 0 fetch-tags: true - uses: actions/setup-node@v6 with: node-version: "22" package-manager-cache: false - name: Install modules env: ELECTRON_SKIP_BINARY_DOWNLOAD: "1" run: npm ci - uses: actions/download-artifact@v8 with: path: artifacts - name: Move artifacts run: | mv artifacts/build dist/ cp -r artifacts/llama.cpp/llama.cpp llama/llama.cpp rm -f ./llama/binariesGithubRelease.json mv artifacts/llama.cpp/binariesGithubRelease.json ./llama/binariesGithubRelease.json rm -f ./llama/llama.cpp.info.json mv artifacts/llama.cpp/llama.cpp.info.json ./llama/llama.cpp.info.json - name: Resolve docs version env: RELEASE_VERSION: ${{ needs.release.outputs.package-version || needs.resolve-next-release.outputs.next-version }} run: | if [ "$RELEASE_VERSION" == "false" ]; then npx --no vite-node ./scripts/resolveLatestReleaseVersion.ts --saveVersionToFile ./docsVersion.txt else echo "$RELEASE_VERSION" > ./docsVersion.txt fi - name: Generate docs with updated version env: DOCS_URL_BASE: "/" run: | export DOCS_PACKAGE_VERSION="$(cat ./docsVersion.txt)" echo "Package version: $DOCS_PACKAGE_VERSION" npm run docs:build - name: Upload docs to GitHub Pages uses: actions/upload-pages-artifact@v5 with: name: pages-docs path: docs-site - name: Deploy docs to GitHub Pages uses: actions/deploy-pages@v5 with: artifact_name: pages-docs - name: Update feed run: | curl -X POST "https://pubsubhubbub.appspot.com/" -H "Content-Type: application/x-www-form-urlencoded" --data-urlencode "hub.mode=publish" --data-urlencode "hub.url=https://node-llama-cpp.withcat.ai/blog/feed.atom" # fix-broken-github-release: # name: Fix broken GitHub release # if: github.event_name == 'pull_request' && github.head_ref == 'gilad/smallerLogoFile' # runs-on: ubuntu-latest # permissions: # id-token: write # actions: read # contents: write # issues: write # pull-requests: write # discussions: write # steps: # - uses: actions/checkout@v6 # - uses: actions/setup-node@v6 # with: # node-version: "22" # package-manager-cache: false # - name: Install modules # env: # ELECTRON_SKIP_BINARY_DOWNLOAD: "1" # run: npm ci # # - name: Pull artifact from broken release # uses: actions/download-artifact@v8 # with: # name: resolved-next-release # github-token: ${{ secrets.GITHUB_TOKEN }} # repository: "${{ github.repository }}" # run-id: "" # path: scripts/resolved-next-release-artifact # # - name: Fix broken release # env: # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # run: npx --no vite-node ./scripts/rerunSemanticReleaseGithubSuccess.ts