mirror of
https://github.com/JefferyHcool/BiliNote.git
synced 2026-06-01 13:40:58 +08:00
Merge pull request #305 from JefferyHcool/feature/optimize-build
Feature/optimize build
This commit is contained in:
83
.github/workflows/main.yml
vendored
83
.github/workflows/main.yml
vendored
@@ -1,10 +1,9 @@
|
|||||||
# .github/workflows/release.yml
|
name: Build & Release Desktop App
|
||||||
name: Build Desktop App (Python Backend + Tauri Frontend)
|
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- 'v*' # 发布 tag 时触发
|
- 'v*'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -13,8 +12,11 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- platform: macos-latest
|
- platform: macos-latest
|
||||||
|
target: universal-apple-darwin
|
||||||
- platform: ubuntu-22.04
|
- platform: ubuntu-22.04
|
||||||
|
target: x86_64-unknown-linux-gnu
|
||||||
- platform: windows-latest
|
- platform: windows-latest
|
||||||
|
target: x86_64-pc-windows-msvc
|
||||||
|
|
||||||
runs-on: ${{ matrix.platform }}
|
runs-on: ${{ matrix.platform }}
|
||||||
|
|
||||||
@@ -57,13 +59,11 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
version: 'latest'
|
version: 'latest'
|
||||||
|
|
||||||
# 设置 Node 环境(带 pnpm 缓存)
|
# 设置 Node 环境
|
||||||
- name: Set up Node.js
|
- name: Set up Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '20'
|
node-version: '20'
|
||||||
cache: 'pnpm'
|
|
||||||
cache-dependency-path: BillNote_frontend/pnpm-lock.yaml
|
|
||||||
|
|
||||||
- name: Install frontend dependencies
|
- name: Install frontend dependencies
|
||||||
working-directory: BillNote_frontend
|
working-directory: BillNote_frontend
|
||||||
@@ -91,17 +91,70 @@ jobs:
|
|||||||
working-directory: BillNote_frontend
|
working-directory: BillNote_frontend
|
||||||
run: pnpm tauri build
|
run: pnpm tauri build
|
||||||
|
|
||||||
# 生成 SHA256 校验和
|
# 收集产物到统一目录
|
||||||
- name: Generate Checksums
|
- name: Collect release artifacts
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
cd BillNote_frontend/src-tauri/target/release/bundle/
|
mkdir -p release-artifacts
|
||||||
find . -type f \( -name "*.dmg" -o -name "*.msi" -o -name "*.deb" -o -name "*.AppImage" \) -exec sha256sum {} \; > checksums.sha256 || true
|
BUNDLE_DIR="BillNote_frontend/src-tauri/target/release/bundle"
|
||||||
|
|
||||||
# 上传构建产物
|
# macOS: .dmg
|
||||||
- name: Upload Desktop Bundle
|
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
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: app-${{ matrix.platform }}
|
name: artifacts-${{ matrix.platform }}
|
||||||
path: |
|
path: release-artifacts/
|
||||||
BillNote_frontend/src-tauri/target/release/bundle/
|
|
||||||
|
# 创建 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/*
|
||||||
|
|||||||
1
BillNote_frontend/.gitignore
vendored
1
BillNote_frontend/.gitignore
vendored
@@ -22,5 +22,4 @@ dist-ssr
|
|||||||
*.njsproj
|
*.njsproj
|
||||||
*.sln
|
*.sln
|
||||||
*.sw?
|
*.sw?
|
||||||
/pnpm-lock.yaml
|
|
||||||
/src-tauri/bin/
|
/src-tauri/bin/
|
||||||
|
|||||||
@@ -31,9 +31,9 @@ RUN corepack enable && corepack prepare pnpm@latest --activate
|
|||||||
|
|
||||||
WORKDIR /tmp/frontend
|
WORKDIR /tmp/frontend
|
||||||
|
|
||||||
# 先复制 lockfile 利用依赖层缓存
|
# 先复制 package.json 利用依赖层缓存
|
||||||
COPY ./BillNote_frontend/package.json ./BillNote_frontend/pnpm-lock.yaml ./
|
COPY ./BillNote_frontend/package.json ./
|
||||||
RUN pnpm install --frozen-lockfile
|
RUN pnpm install
|
||||||
|
|
||||||
COPY ./BillNote_frontend /tmp/frontend
|
COPY ./BillNote_frontend /tmp/frontend
|
||||||
RUN pnpm run build
|
RUN pnpm run build
|
||||||
|
|||||||
Reference in New Issue
Block a user