forked from Wei-Shaw/sub2api
-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (60 loc) · 1.84 KB
/
Copy pathopencode-build.yml
File metadata and controls
71 lines (60 loc) · 1.84 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
name: Build sub2api (opencode-pool)
# Fork 专用构建:产出单文件 linux/amd64 二进制(含前端 embed)。
# 手动触发:构建 + 上传 artifact;
# tag 推送(v*):构建 + 上传 artifact + 发布 GitHub Release(服务器部署脚本从此拉取)。
on:
workflow_dispatch:
push:
branches:
- main
tags:
- 'v*'
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup pnpm
uses: pnpm/action-setup@v6
with:
version: 9
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '20'
cache: 'pnpm'
cache-dependency-path: frontend/pnpm-lock.yaml
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: '1.26.x'
cache-dependency-path: backend/go.sum
- name: Build frontend
run: |
pnpm install --frozen-lockfile
pnpm run build
working-directory: frontend
- name: Build backend (linux/amd64, embedded frontend)
run: make -C backend build
env:
CGO_ENABLED: '0'
GOOS: linux
GOARCH: amd64
# 前端通过 //go:build embed 嵌入(backend/internal/web/embed_on.go),
# 不带该 tag 的构建无前端托管,根路径会返回 404。
GOFLAGS: '-tags=embed'
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: sub2api-linux-amd64
path: backend/bin/server
retention-days: 14
- name: Publish release (tags only)
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: backend/bin/server
generate_release_notes: true