Skip to content
This repository was archived by the owner on Jan 2, 2026. It is now read-only.

Commit ddadc70

Browse files
committed
ci: add build
1 parent 59e868a commit ddadc70

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed

.github/workflows/build.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Build Backend with Frontend
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
goos: [linux, windows]
15+
goarch: [amd64]
16+
17+
steps:
18+
# 1. Checkout 后端仓库
19+
- name: Checkout code
20+
uses: actions/checkout@v5
21+
22+
# 2. 下载前端 zip
23+
- name: Download frontend build
24+
run: |
25+
curl -L -o canteen-frontend-build.zip https://nightly.link/itsHenry35/canteen-management-system-frontend/workflows/build/master/canteen-frontend-build.zip
26+
27+
# 3. 安装 unzip
28+
- name: Install unzip
29+
run: sudo apt-get update && sudo apt-get install -y unzip
30+
31+
# 4. 解压到 static/
32+
- name: Unzip frontend
33+
run: |
34+
mkdir -p static
35+
unzip -o canteen-frontend-build.zip -d static
36+
37+
# 5. 设置 Go 交叉编译环境
38+
- name: Setup Go
39+
uses: actions/setup-go@v5
40+
with:
41+
go-version: 1.24
42+
43+
# 6. 安装交叉编译依赖(Linux + Windows 64bit, CGO_ENABLED=1)
44+
- name: Install cross compilation dependencies
45+
if: matrix.goos == 'linux'
46+
run: sudo apt-get install -y gcc-multilib
47+
- name: Install cross compilation dependencies for Windows
48+
if: matrix.goos == 'windows'
49+
run: sudo apt-get install -y gcc-mingw-w64
50+
51+
# 7. 编译
52+
- name: Build binary
53+
env:
54+
CGO_ENABLED: 1
55+
GOOS: ${{ matrix.goos }}
56+
GOARCH: ${{ matrix.goarch }}
57+
run: |
58+
go build -o build/myapp-${{ matrix.goos }}-${{ matrix.goarch }}
59+
60+
# 8. 上传构建产物
61+
- name: Upload artifacts
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: myapp-${{ matrix.goos }}-${{ matrix.goarch }}
65+
path: build/myapp-${{ matrix.goos }}-${{ matrix.goarch }}

.github/workflows/jekyll-gh-pages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
runs-on: ubuntu-latest
2424
steps:
2525
- name: Checkout
26-
uses: actions/checkout@v4
26+
uses: actions/checkout@v5
2727
- name: Setup Pages
2828
uses: actions/configure-pages@v5
2929
- name: Build with Jekyll

0 commit comments

Comments
 (0)