-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (70 loc) · 2.75 KB
/
build.yml
File metadata and controls
84 lines (70 loc) · 2.75 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
name: Build Action # 工作流的名称
on:
push:
tags:
- 'v*'
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout Code
uses: actions/checkout@v6
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: '1.26'
cache: true
- name: Setup pnpm
uses: pnpm/action-setup@v6
with:
version: latest
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
cache: 'pnpm' # 自动缓存 pnpm 依赖
cache-dependency-path: website/pnpm-lock.yaml
- name: Verify versions
run: |
go version
node -v
pnpm -v
- name: Install dependencies
working-directory: ./website
run: |
pnpm install --frozen-lockfile || true
pnpm approve-builds --all
- name: Build Frontend
working-directory: ./website
run: |
pnpm install --frozen-lockfile
pnpm build
# 假设你的 SvelteKit 导出目录是 website/build
# 确保 pb_public 文件夹存在
mkdir -p ../pb_public
cp -r build/* ../pb_public/
- name: Build Go Binary
run: |
# 禁用 CGO 以实现静态链接,确保二进制文件在不同 Linux 发行版都能跑
export CGO_ENABLED=0
export TAG_NAME=${GITHUB_REF#refs/tags/}
GOOS=linux GOARCH=amd64 go build -ldflags "-X 'main.Version=${{github.ref_name}}'" -o "pdnode-cp-${TAG_NAME}-linux" .
GOOS=windows GOARCH=amd64 go build -ldflags "-X 'main.Version=${{github.ref_name}}'" -o "pdnode-cp-${TAG_NAME}-windows.exe" .
- name: Create Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
pdnode-cp-*-linux
pdnode-cp-*-windows.exe
# 这里的 token 是 GitHub 自动提供的,不需要你手动设置
token: ${{ secrets.GITHUB_TOKEN }}
prerelease: ${{ contains(github.ref, '-alpha') || contains(github.ref, '-beta') || contains(github.ref, '-dev') || contains(github.ref, '-rc') }}
body: |
${{ (contains(github.ref, '-alpha') || contains(github.ref, '-beta') || contains(github.ref, '-dev') || contains(github.ref, '-rc')) && '> [!CAUTION]
> **This is a Pre-release Version**
> This version is intended for testing purposes only and may contain unstable elements; please do not use it in a production environment.
---' || '' }}
generate_release_notes: true # 自动根据 commit 生成更新日志