CI: add matrix builds & cross-platform packaging
Restructure GitHub Actions to build Windows and Linux matrix targets and produce platform-specific artifacts. - .github/workflows/dev-build.yml: split cleanup/build jobs, add matrix (win-x64, linux-x64), set SNOWLUMA_TARGET for builds, produce full and -lite archives (.zip on Windows, .tar.gz on Linux), unify upload step and ensure errors when artifacts missing. - .github/workflows/release.yml: convert release build to matrix, produce platform archives, download/collect artifacts, generate multi-platform release notes (bash), and create the GitHub release with both .zip and .tar.gz assets. - packages/core/vite.config.ts: add fs import and SNOWLUMA_TARGET handling, pick platform-specific runtime files (launcher.bat or launcher.sh), enumerate native files per target, fail CI if expected native binaries are missing, and copy native files into dist/native. - packages/runtime/launcher.sh: add a portable launcher for Linux that prefers a bundled node binary or falls back to PATH and execs index.mjs. These changes enable cross-target CI packaging and enforce that native binaries are present before releasing.
This commit is contained in:
1 parent
df73f58598
commit
82c1721466
4 files changed
+191
-83
No files matched your search
@@ -8,8 +8,8 @@ on:
|
|||||||
- 'v*'
|
- 'v*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
cleanup:
|
||||||
runs-on: windows-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
actions: write
|
actions: write
|
||||||
contents: read
|
contents: read
|
||||||
@@ -38,6 +38,25 @@ jobs:
|
|||||||
page++;
|
page++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
build:
|
||||||
|
needs: cleanup
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- name: win-x64
|
||||||
|
os: windows-latest
|
||||||
|
target: win32-x64
|
||||||
|
- name: linux-x64
|
||||||
|
os: ubuntu-latest
|
||||||
|
target: linux-x64
|
||||||
|
- name: linux-arm64
|
||||||
|
os: ubuntu-24.04-arm
|
||||||
|
target: linux-arm64
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
@@ -58,45 +77,41 @@ jobs:
|
|||||||
|
|
||||||
# Always builds the WebUI flavor — no separate "core-only" artifact.
|
# Always builds the WebUI flavor — no separate "core-only" artifact.
|
||||||
- name: Build project
|
- name: Build project
|
||||||
|
env:
|
||||||
|
SNOWLUMA_TARGET: ${{ matrix.target }}
|
||||||
run: pnpm run build:all
|
run: pnpm run build:all
|
||||||
|
|
||||||
- name: Verify native files
|
|
||||||
shell: pwsh
|
|
||||||
run: |
|
|
||||||
if (!(Test-Path "dist\native\snowluma-win32-x64.node")) { throw "Missing dist\native\snowluma-win32-x64.node" }
|
|
||||||
if (!(Test-Path "dist\native\snowluma-win32-x64.dll")) { throw "Missing dist\native\snowluma-win32-x64.dll" }
|
|
||||||
if (!(Test-Path "dist\native\websocket-win32-x64.node")) { throw "Missing dist\native\websocket-win32-x64.node" }
|
|
||||||
|
|
||||||
- name: Bundle runtime dependencies
|
- name: Bundle runtime dependencies
|
||||||
working-directory: dist
|
working-directory: dist
|
||||||
run: npm install --omit=dev
|
run: npm install --omit=dev
|
||||||
|
|
||||||
# Two artifacts:
|
# Naming convention:
|
||||||
# * SnowLuma-dev.zip – full bundle, ships node.exe (zero-install)
|
# SnowLuma-dev-<arch>.zip|tar.gz – zero-install (node bundled)
|
||||||
# * SnowLuma-dev-no-node.zip – same bundle without node.exe (user provides Node >= 22)
|
# SnowLuma-dev-<arch>-lite.zip|tar.gz – user provides Node >= 22
|
||||||
- name: Package artifact (no-node)
|
- name: Package (windows)
|
||||||
shell: pwsh
|
if: matrix.os == 'windows-latest'
|
||||||
run: |
|
|
||||||
Compress-Archive -Path "dist\*" -DestinationPath "SnowLuma-dev-no-node.zip"
|
|
||||||
|
|
||||||
- name: Package artifact (with node.exe)
|
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
run: |
|
run: |
|
||||||
|
Compress-Archive -Path "dist\*" -DestinationPath "SnowLuma-dev-${{ matrix.name }}-lite.zip"
|
||||||
Copy-Item (Get-Command node).Source -Destination "dist\node.exe"
|
Copy-Item (Get-Command node).Source -Destination "dist\node.exe"
|
||||||
Compress-Archive -Path "dist\*" -DestinationPath "SnowLuma-dev.zip"
|
Compress-Archive -Path "dist\*" -DestinationPath "SnowLuma-dev-${{ matrix.name }}.zip"
|
||||||
|
|
||||||
- name: Upload artifact (with node.exe)
|
- name: Package (linux)
|
||||||
|
if: startsWith(matrix.os, 'ubuntu')
|
||||||
|
run: |
|
||||||
|
chmod +x dist/launcher.sh
|
||||||
|
tar -czf "SnowLuma-dev-${{ matrix.name }}-lite.tar.gz" -C dist .
|
||||||
|
cp "$(command -v node)" dist/node
|
||||||
|
chmod +x dist/node
|
||||||
|
tar -czf "SnowLuma-dev-${{ matrix.name }}.tar.gz" -C dist .
|
||||||
|
|
||||||
|
# Single upload step — glob picks up both variants (.zip on Windows,
|
||||||
|
# .tar.gz on Linux) for this matrix row.
|
||||||
|
- name: Upload artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: SnowLuma-dev-${{ github.sha }}
|
name: SnowLuma-dev-${{ github.sha }}-${{ matrix.name }}
|
||||||
path: SnowLuma-dev.zip
|
path: SnowLuma-dev-${{ matrix.name }}*
|
||||||
retention-days: 3
|
|
||||||
overwrite: true
|
|
||||||
|
|
||||||
- name: Upload artifact (no-node)
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: SnowLuma-dev-${{ github.sha }}-no-node
|
|
||||||
path: SnowLuma-dev-no-node.zip
|
|
||||||
retention-days: 3
|
retention-days: 3
|
||||||
overwrite: true
|
overwrite: true
|
||||||
|
if-no-files-found: error
|
||||||
@@ -10,7 +10,20 @@ permissions:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: windows-latest
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- name: win-x64
|
||||||
|
os: windows-latest
|
||||||
|
target: win32-x64
|
||||||
|
- name: linux-x64
|
||||||
|
os: ubuntu-latest
|
||||||
|
target: linux-x64
|
||||||
|
- name: linux-arm64
|
||||||
|
os: ubuntu-24.04-arm
|
||||||
|
target: linux-arm64
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -34,70 +47,112 @@ jobs:
|
|||||||
|
|
||||||
# Always builds the WebUI flavor — no separate "core-only" artifact.
|
# Always builds the WebUI flavor — no separate "core-only" artifact.
|
||||||
- name: Build project
|
- name: Build project
|
||||||
|
env:
|
||||||
|
SNOWLUMA_TARGET: ${{ matrix.target }}
|
||||||
run: pnpm run build:all
|
run: pnpm run build:all
|
||||||
|
|
||||||
- name: Verify native files
|
|
||||||
shell: pwsh
|
|
||||||
run: |
|
|
||||||
if (!(Test-Path "dist\native\snowluma-win32-x64.node")) { throw "Missing dist\native\snowluma-win32-x64.node" }
|
|
||||||
if (!(Test-Path "dist\native\snowluma-win32-x64.dll")) { throw "Missing dist\native\snowluma-win32-x64.dll" }
|
|
||||||
if (!(Test-Path "dist\native\websocket-win32-x64.node")) { throw "Missing dist\native\websocket-win32-x64.node" }
|
|
||||||
|
|
||||||
- name: Bundle runtime dependencies
|
- name: Bundle runtime dependencies
|
||||||
working-directory: dist
|
working-directory: dist
|
||||||
run: npm install --omit=dev
|
run: npm install --omit=dev
|
||||||
|
|
||||||
# Two release archives:
|
# Naming convention:
|
||||||
# * SnowLuma-<tag>-win-x64.zip – zero-install bundle (ships node.exe)
|
# SnowLuma-<tag>-<arch>.zip|tar.gz – zero-install (node bundled)
|
||||||
# * SnowLuma-<tag>-win-x64-no-node.zip – same bundle without node.exe
|
# SnowLuma-<tag>-<arch>-lite.zip|tar.gz – user provides Node >= 22
|
||||||
- name: Package release (no-node)
|
- name: Package (windows)
|
||||||
shell: pwsh
|
if: matrix.os == 'windows-latest'
|
||||||
run: |
|
|
||||||
Compress-Archive -Path "dist\*" -DestinationPath "SnowLuma-${{ github.ref_name }}-win-x64-no-node.zip"
|
|
||||||
|
|
||||||
- name: Package release (with node.exe)
|
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
run: |
|
run: |
|
||||||
|
Compress-Archive -Path "dist\*" -DestinationPath "SnowLuma-${{ github.ref_name }}-${{ matrix.name }}-lite.zip"
|
||||||
Copy-Item (Get-Command node).Source -Destination "dist\node.exe"
|
Copy-Item (Get-Command node).Source -Destination "dist\node.exe"
|
||||||
Compress-Archive -Path "dist\*" -DestinationPath "SnowLuma-${{ github.ref_name }}-win-x64.zip"
|
Compress-Archive -Path "dist\*" -DestinationPath "SnowLuma-${{ github.ref_name }}-${{ matrix.name }}.zip"
|
||||||
|
|
||||||
|
- name: Package (linux)
|
||||||
|
if: startsWith(matrix.os, 'ubuntu')
|
||||||
|
run: |
|
||||||
|
chmod +x dist/launcher.sh
|
||||||
|
tar -czf "SnowLuma-${{ github.ref_name }}-${{ matrix.name }}-lite.tar.gz" -C dist .
|
||||||
|
cp "$(command -v node)" dist/node
|
||||||
|
chmod +x dist/node
|
||||||
|
tar -czf "SnowLuma-${{ github.ref_name }}-${{ matrix.name }}.tar.gz" -C dist .
|
||||||
|
|
||||||
|
- name: Upload build artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: release-${{ matrix.name }}
|
||||||
|
path: SnowLuma-${{ github.ref_name }}-${{ matrix.name }}*
|
||||||
|
if-no-files-found: error
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
release:
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout (for git log)
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Download all artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
path: artifacts
|
||||||
|
|
||||||
|
- name: Collect release assets
|
||||||
|
run: |
|
||||||
|
mkdir -p release
|
||||||
|
find artifacts -type f \( -name '*.zip' -o -name '*.tar.gz' \) -exec cp {} release/ \;
|
||||||
|
ls -lh release/
|
||||||
|
|
||||||
- name: Generate release note
|
- name: Generate release note
|
||||||
shell: pwsh
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
$tag = "${{ github.ref_name }}"
|
tag="${GITHUB_REF_NAME}"
|
||||||
$previousTag = git describe --tags --abbrev=0 "$tag^" 2>$null
|
previousTag="$(git describe --tags --abbrev=0 "${tag}^" 2>/dev/null || true)"
|
||||||
if ($LASTEXITCODE -ne 0) { $previousTag = "" }
|
if [[ -n "$previousTag" ]]; then
|
||||||
if ($previousTag) {
|
changes="$(git log --pretty=format:'- %s (%h)' "$previousTag..$tag")"
|
||||||
$range = "$previousTag..$tag"
|
else
|
||||||
$changes = git log --pretty=format:"- %s (%h)" $range
|
changes="$(git log --pretty=format:'- %s (%h)' "$tag")"
|
||||||
} else {
|
fi
|
||||||
$changes = git log --pretty=format:"- %s (%h)" $tag
|
[[ -z "$changes" ]] && changes="- No commit changes detected."
|
||||||
}
|
cat > release-notes.md <<EOF
|
||||||
if (!$changes) { $changes = "- No commit changes detected." }
|
# SnowLuma ${tag}
|
||||||
$body = @"
|
|
||||||
# SnowLuma $tag
|
|
||||||
|
|
||||||
## 发布概览
|
## 发布概览
|
||||||
本次发布提供 SnowLuma 的 Windows x64 构建产物,默认包含 WebUI。
|
本次发布提供 SnowLuma 的 Windows x64 / Linux x64 / Linux arm64 构建产物,默认包含 WebUI。
|
||||||
|
|
||||||
## 下载说明
|
## 下载说明
|
||||||
- ``SnowLuma-$tag-win-x64.zip``:完整版本,内置 ``node.exe`` 与运行时依赖,解压即可使用。
|
命名约定:
|
||||||
- ``SnowLuma-$tag-win-x64-no-node.zip``:不含 ``node.exe``,需自行安装 Node.js 22 及以上版本后再运行 ``launcher.bat`` 或 ``node index.mjs``。
|
- 无后缀 \`.zip/.tar.gz\`:完整版本,内置 \`node\`/\`node.exe\` 与运行时依赖,解压即可使用。
|
||||||
|
- \`-lite\` 后缀:精简版本,不含 Node.js 运行时,需自行安装 Node.js 22+。
|
||||||
|
|
||||||
|
Windows:
|
||||||
|
- \`SnowLuma-${tag}-win-x64.zip\`
|
||||||
|
- \`SnowLuma-${tag}-win-x64-lite.zip\`
|
||||||
|
|
||||||
|
Linux x64:
|
||||||
|
- \`SnowLuma-${tag}-linux-x64.tar.gz\`
|
||||||
|
- \`SnowLuma-${tag}-linux-x64-lite.tar.gz\`
|
||||||
|
|
||||||
|
Linux arm64:
|
||||||
|
- \`SnowLuma-${tag}-linux-arm64.tar.gz\`
|
||||||
|
- \`SnowLuma-${tag}-linux-arm64-lite.tar.gz\`
|
||||||
|
|
||||||
## 更新内容
|
## 更新内容
|
||||||
$changes
|
${changes}
|
||||||
|
|
||||||
## 使用说明
|
## 使用说明
|
||||||
- 仅支持 Windows x64 环境。
|
- Windows x64:\`launcher.bat\` 或 \`node index.mjs\`。
|
||||||
- 两个压缩包均已内置 WebUI 静态资源;启动后访问 http://localhost:8080 选择进程、调整配置或查看日志。
|
- Linux:\`./launcher.sh\` 或 \`node index.mjs\`。
|
||||||
- ``no-node`` 版本要求系统 ``node`` 可执行文件版本 >= 22。
|
- 所有压缩包均已内置 WebUI 静态资源;启动后访问 http://localhost:8080。
|
||||||
"@
|
- Linux 版本仅提供 OneBot 桥接能力,NTQQ 进程注入仅在 Windows 下生效。
|
||||||
$body -replace "(?m)^ ", "" | Set-Content -Path "release-notes.md" -Encoding utf8
|
EOF
|
||||||
|
|
||||||
- name: Create GitHub Release
|
- name: Create GitHub Release
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
files: SnowLuma-*.zip
|
files: |
|
||||||
|
release/*.zip
|
||||||
|
release/*.tar.gz
|
||||||
body_path: release-notes.md
|
body_path: release-notes.md
|
||||||
overwrite_files: true
|
overwrite_files: true
|
||||||
draft: false
|
draft: false
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { defineConfig, PluginOption, UserConfig } from 'vite';
|
import { defineConfig, PluginOption, UserConfig } from 'vite';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { builtinModules } from 'module';
|
import { builtinModules } from 'module';
|
||||||
import cp from 'vite-plugin-cp';
|
import cp from 'vite-plugin-cp';
|
||||||
@@ -22,19 +23,40 @@ const nodeModules = [...builtinModules, ...builtinModules.map((m) => `node:${m}`
|
|||||||
const runtimeSrc = toPosix(runtimeDir);
|
const runtimeSrc = toPosix(runtimeDir);
|
||||||
const nativeSrc = toPosix(nativeDir);
|
const nativeSrc = toPosix(nativeDir);
|
||||||
|
|
||||||
// Only the runtime distribution assets land in dist/.
|
// Target selection: `SNOWLUMA_TARGET=<platform>-<arch>` overrides the host
|
||||||
// (.gitignore and other dev artifacts must NOT be shipped.)
|
// detection, enabling cross-target packaging on CI.
|
||||||
const runtimeDistFiles = ['launcher.bat', 'package.json'];
|
|
||||||
|
|
||||||
// Only ship native binaries matching the current build host's platform/arch.
|
|
||||||
// Override via SNOWLUMA_TARGET=<platform>-<arch> for cross-target packaging.
|
|
||||||
const targetTriple = process.env.SNOWLUMA_TARGET ?? `${process.platform}-${process.arch}`;
|
const targetTriple = process.env.SNOWLUMA_TARGET ?? `${process.platform}-${process.arch}`;
|
||||||
const nativeGlobs = [
|
const targetPlatform = targetTriple.split('-')[0];
|
||||||
`snowluma-${targetTriple}.dll`,
|
|
||||||
`snowluma-${targetTriple}.node`,
|
// Runtime scaffolding files copied into dist/. The NTQQ hook is Windows-only,
|
||||||
`websocket-${targetTriple}.node`,
|
// so its launcher/shell script differ per target.
|
||||||
|
const runtimeDistFiles = ['package.json',
|
||||||
|
targetPlatform === 'win32' ? 'launcher.bat' : 'launcher.sh',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Native binaries shipped for the selected target:
|
||||||
|
// * `snowluma-*.{dll,node}` – NTQQ hook (Windows-only).
|
||||||
|
// * `websocket-*.node` – RFC 6455 framing/mask addon (all platforms).
|
||||||
|
const nativeFiles = [
|
||||||
|
`websocket-${targetTriple}.node`,
|
||||||
|
...(targetPlatform === 'win32'
|
||||||
|
? [`snowluma-${targetTriple}.dll`, `snowluma-${targetTriple}.node`]
|
||||||
|
: []),
|
||||||
|
];
|
||||||
|
|
||||||
|
// Fail fast if any expected native binary is missing from packages/runtime/native/.
|
||||||
|
// vite-plugin-cp only emits a warning on missing source files; we want a hard
|
||||||
|
// error so CI can't accidentally ship an incomplete archive.
|
||||||
|
const missingNatives = nativeFiles.filter(
|
||||||
|
(f) => !fs.existsSync(path.join(nativeDir, f)),
|
||||||
|
);
|
||||||
|
if (missingNatives.length > 0) {
|
||||||
|
throw new Error(
|
||||||
|
`Missing native binaries for target ${targetTriple}:\n` +
|
||||||
|
missingNatives.map((f) => ` - ${path.join(nativeDir, f)}`).join('\n'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const BaseConfigPlugin: PluginOption[] = [
|
const BaseConfigPlugin: PluginOption[] = [
|
||||||
cp({
|
cp({
|
||||||
targets: [
|
targets: [
|
||||||
@@ -43,8 +65,8 @@ const BaseConfigPlugin: PluginOption[] = [
|
|||||||
dest: distDir,
|
dest: distDir,
|
||||||
flatten: true,
|
flatten: true,
|
||||||
})),
|
})),
|
||||||
...nativeGlobs.map((g) => ({
|
...nativeFiles.map((f) => ({
|
||||||
src: `${nativeSrc}/${g}`,
|
src: `${nativeSrc}/${f}`,
|
||||||
dest: path.join(distDir, 'native'),
|
dest: path.join(distDir, 'native'),
|
||||||
flatten: true,
|
flatten: true,
|
||||||
})),
|
})),
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
|
# Prefer bundled node when present; fall back to $PATH.
|
||||||
|
if [[ -x "./node" ]]; then
|
||||||
|
NODE_BIN="./node"
|
||||||
|
else
|
||||||
|
NODE_BIN="$(command -v node || true)"
|
||||||
|
if [[ -z "$NODE_BIN" ]]; then
|
||||||
|
echo "error: 'node' not found on PATH and no bundled ./node; install Node.js >= 22." >&2
|
||||||
|
exit 127
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$NODE_BIN" ./index.mjs "$@"
|
||||||
Reference in new issue
Block a user