-
Notifications
You must be signed in to change notification settings - Fork 1
109 lines (91 loc) · 3.12 KB
/
deploy.yml
File metadata and controls
109 lines (91 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# =============================================================================
# RustQuantLab - GitHub Pages Deployment Workflow
# =============================================================================
# Triggered on push to main branch
# Builds Rust/Wasm + Vite frontend and deploys to GitHub Pages
# =============================================================================
name: Deploy to GitHub Pages
on:
push:
branches:
- main
workflow_dispatch: # Allow manual trigger
# Sets permissions for GITHUB_TOKEN to deploy to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
# ===== 1. Checkout Code =====
- name: 📥 Checkout repository
uses: actions/checkout@v4
# ===== 2. Setup Rust Toolchain =====
- name: 🦀 Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
# ===== 3. Cache Rust dependencies =====
- name: 📦 Cache Cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
core/target
key: ${{ runner.os }}-cargo-${{ hashFiles('core/Cargo.lock', 'core/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-
# ===== 4. Run Rust Tests (仅 PR 或手动触发时) =====
- name: 🧪 Run Rust tests
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
run: |
cd core
cargo test --lib --release
cd ..
# ===== 5. Cache & Install wasm-pack =====
- name: 📦 Cache wasm-pack
uses: actions/cache@v4
id: wasm-pack-cache
with:
path: ~/.cargo/bin/wasm-pack
key: ${{ runner.os }}-wasm-pack-0.13.0
- name: 📦 Install wasm-pack
if: steps.wasm-pack-cache.outputs.cache-hit != 'true'
run: cargo install wasm-pack --locked
# ===== 6. Setup Node.js =====
- name: 🟢 Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
# ===== 7. Install npm dependencies =====
- name: 📦 Install npm dependencies
run: npm ci
# ===== 8. Build Rust → WebAssembly =====
- name: 🔨 Build Rust to WebAssembly
run: |
cd core
wasm-pack build --target web --out-dir pkg --release
cd ..
# ===== 9. Build Frontend (Vite) =====
- name: 🏗️ Build frontend
run: npx vite build --base=/RustQuantLab/
# ===== 10. Setup GitHub Pages =====
- name: 📄 Setup Pages
uses: actions/configure-pages@v4
# ===== 11. Upload artifact =====
- name: 📤 Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: './dist'
# ===== 12. Deploy to GitHub Pages =====
- name: 🚀 Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4