160 lines
5.0 KiB
YAML
160 lines
5.0 KiB
YAML
name: Build and Release
|
||
|
||
on:
|
||
push:
|
||
tags:
|
||
- 'v*'
|
||
|
||
permissions:
|
||
contents: write
|
||
|
||
jobs:
|
||
build:
|
||
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
|
||
uses: actions/checkout@v6
|
||
with:
|
||
fetch-depth: 0
|
||
|
||
- name: Setup pnpm
|
||
uses: pnpm/action-setup@v6
|
||
with:
|
||
version: 10.28.0
|
||
run_install: false
|
||
|
||
- name: Setup Node.js
|
||
uses: actions/setup-node@v6
|
||
with:
|
||
node-version: '22'
|
||
cache: 'pnpm'
|
||
|
||
- name: Install dependencies
|
||
run: pnpm install --frozen-lockfile
|
||
|
||
# Always builds the WebUI flavor — no separate "core-only" artifact.
|
||
- name: Build project
|
||
env:
|
||
SNOWLUMA_TARGET: ${{ matrix.target }}
|
||
run: pnpm run build:all
|
||
|
||
- name: Bundle runtime dependencies
|
||
working-directory: dist
|
||
run: npm install --omit=dev
|
||
|
||
# Naming convention:
|
||
# SnowLuma-<tag>-<arch>.zip|tar.gz – zero-install (node bundled)
|
||
# SnowLuma-<tag>-<arch>-lite.zip|tar.gz – user provides Node >= 22
|
||
- name: Package (windows)
|
||
if: matrix.os == 'windows-latest'
|
||
shell: pwsh
|
||
run: |
|
||
Compress-Archive -Path "dist\*" -DestinationPath "SnowLuma-${{ github.ref_name }}-${{ matrix.name }}-lite.zip"
|
||
Copy-Item (Get-Command node).Source -Destination "dist\node.exe"
|
||
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@v7
|
||
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@v6
|
||
with:
|
||
fetch-depth: 0
|
||
|
||
- name: Download all artifacts
|
||
uses: actions/download-artifact@v7
|
||
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
|
||
shell: bash
|
||
run: |
|
||
tag="${GITHUB_REF_NAME}"
|
||
previousTag="$(git describe --tags --abbrev=0 "${tag}^" 2>/dev/null || true)"
|
||
if [[ -n "$previousTag" ]]; then
|
||
changes="$(git log --pretty=format:'- %s (%h)' "$previousTag..$tag")"
|
||
else
|
||
changes="$(git log --pretty=format:'- %s (%h)' "$tag")"
|
||
fi
|
||
[[ -z "$changes" ]] && changes="- No commit changes detected."
|
||
cat > release-notes.md <<EOF
|
||
# SnowLuma ${tag}
|
||
|
||
## 发布概览
|
||
本次发布提供 SnowLuma 的 Windows x64 / Linux x64 / Linux arm64 构建产物,默认包含 WebUI。
|
||
|
||
## 下载说明
|
||
命名约定:
|
||
- 无后缀 \`.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}
|
||
|
||
## 使用说明
|
||
- Windows x64:\`launcher.bat\` 或 \`node index.mjs\`。
|
||
- Linux:\`./launcher.sh\` 或 \`node index.mjs\`。
|
||
- 所有压缩包均已内置 WebUI 静态资源;启动后访问 http://localhost:5099。
|
||
- Linux 版本仅提供 OneBot 桥接能力,NTQQ 进程注入仅在 Windows 下生效。
|
||
EOF
|
||
|
||
- name: Create GitHub Release
|
||
uses: softprops/action-gh-release@v2
|
||
with:
|
||
files: |
|
||
release/*.zip
|
||
release/*.tar.gz
|
||
body_path: release-notes.md
|
||
overwrite_files: true
|
||
draft: false
|
||
prerelease: ${{ contains(github.ref_name, '-') }}
|