Files
BiliNote/.github/workflows/main.yml
huangjianwu 6d5d1ad373 fix(ci): 修复 GitHub Actions 构建错误
移除 setup-node 中的 pnpm 缓存配置以修复 macOS 构建失败,修改 Dockerfile 不再依赖 pnpm-lock.yaml 以修复 Docker 构建失败

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-23 18:11:55 +08:00

161 lines
4.6 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: Build & Release Desktop App
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
build:
strategy:
matrix:
include:
- platform: macos-latest
target: universal-apple-darwin
- platform: ubuntu-22.04
target: x86_64-unknown-linux-gnu
- platform: windows-latest
target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
# Linux 系统依赖Tauri 需要)
- name: Install Linux Dependencies
if: matrix.platform == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
# 设置 Python 环境(带 pip 缓存)
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: backend/requirements.txt
# 安装 Python 依赖并执行构建
- name: Install Python dependencies & Build backend
shell: bash
run: |
python -m pip install --upgrade pip
pip install -r backend/requirements.txt
if [ "$RUNNER_OS" = "Windows" ]; then
backend\\build.bat
else
chmod +x backend/build.sh
./backend/build.sh
fi
# 设置 pnpm
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 'latest'
# 设置 Node 环境
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install frontend dependencies
working-directory: BillNote_frontend
run: pnpm install --frozen-lockfile
# 设置 Rust 环境
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
# Cargo 缓存
- name: Cache Cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
BillNote_frontend/src-tauri/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('BillNote_frontend/src-tauri/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
# 打包 Tauri 应用
- name: Build Tauri App
working-directory: BillNote_frontend
run: pnpm tauri build
# 收集产物到统一目录
- name: Collect release artifacts
shell: bash
run: |
mkdir -p release-artifacts
BUNDLE_DIR="BillNote_frontend/src-tauri/target/release/bundle"
# macOS: .dmg
find "$BUNDLE_DIR" -name "*.dmg" -exec cp {} release-artifacts/ \; 2>/dev/null || true
# Windows: .msi, .exe (NSIS)
find "$BUNDLE_DIR" -name "*.msi" -exec cp {} release-artifacts/ \; 2>/dev/null || true
find "$BUNDLE_DIR/nsis" -name "*.exe" -exec cp {} release-artifacts/ \; 2>/dev/null || true
# Linux: .deb, .AppImage
find "$BUNDLE_DIR" -name "*.deb" -exec cp {} release-artifacts/ \; 2>/dev/null || true
find "$BUNDLE_DIR" -name "*.AppImage" -exec cp {} release-artifacts/ \; 2>/dev/null || true
echo "=== Collected artifacts ==="
ls -lh release-artifacts/
# 生成 SHA256 校验和
- name: Generate checksums
shell: bash
run: |
cd release-artifacts
sha256sum * > SHA256SUMS.txt 2>/dev/null || shasum -a 256 * > SHA256SUMS.txt
cat SHA256SUMS.txt
# 上传产物(供 release job 使用)
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts-${{ matrix.platform }}
path: release-artifacts/
# 创建 GitHub Release 并上传所有产物
release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- name: Checkout Code
uses: actions/checkout@v4
# 下载所有平台的构建产物
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: all-artifacts
merge-multiple: true
- name: List all artifacts
run: |
echo "=== All release artifacts ==="
ls -lhR all-artifacts/
# 创建 Release 并上传产物
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: BiliNote ${{ github.ref_name }}
draft: false
prerelease: false
generate_release_notes: true
files: all-artifacts/*