Skip to content

Commit e804201

Browse files
committed
github 工作流
1 parent 72214ef commit e804201

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Cross-Platform Bun Build (三系统构建)
2+
3+
# 1. 触发条件:当代码推送到 main 分支,或发起针对 main 分支的 Pull Request 时运行
4+
on:
5+
push:
6+
branches: [ main ]
7+
pull_request:
8+
branches: [ main ]
9+
10+
# 2. 定义任务 (Job)
11+
jobs:
12+
build:
13+
# 使用矩阵策略,对列表中的所有 OS 进行构建
14+
runs-on: ${{ matrix.os }}
15+
16+
strategy:
17+
# 定义构建矩阵,确保在三个系统上执行
18+
matrix:
19+
os: [ubuntu-latest, macos-latest, windows-latest]
20+
bun-version: [latest]
21+
22+
steps:
23+
- name: 📝 检出代码 (Checkout code)
24+
uses: actions/checkout@v4
25+
26+
- name: 🛠️ 设置 Bun (${{ matrix.bun-version }})
27+
# 使用官方 Action 来安装 Bun
28+
uses: oven-sh/setup-bun@v1
29+
with:
30+
bun-version: ${{ matrix.bun-version }}
31+
32+
- name: 📦 安装依赖 (bun install)
33+
# --frozen-lockfile 确保所有系统使用相同的锁定文件
34+
run: bun install --frozen-lockfile
35+
36+
- name: 🔨 执行构建 (bun run build)
37+
# 这是构建产物(如 dist 文件夹)的关键步骤
38+
run: bun run build
39+
40+
- name: 💾 存档构建结果 (${{ matrix.os }})
41+
uses: actions/upload-artifact@v4
42+
with:
43+
# 产物名称会根据操作系统动态变化:
44+
# build-artifacts-ubuntu-latest, build-artifacts-macos-latest, build-artifacts-windows-latest
45+
name: build-artifacts-${{ matrix.os }}
46+
47+
# **重点:确保你的 bun run build 脚本将文件输出到这个目录**
48+
path: dist
49+
50+
# 如果找不到 dist 目录,则强制工作流失败,以便你发现构建问题
51+
if-no-files-found: error

0 commit comments

Comments
 (0)