章节重排 与 test拆分 (#32) #33
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Go Build | |
on: | |
push: | |
branches: | |
- main # 触发构建的分支 | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# 检出代码 | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
# 安装必要依赖 | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libasound2-dev pkg-config | |
# 设置 Go 环境 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: 1.22.4 # 根据你的项目使用的 Go 版本调整 | |
# 缓存 Go 依赖 | |
- name: Cache Go modules | |
uses: actions/cache@v3 | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
# 切换到项目目录并安装依赖 | |
- name: Install dependencies | |
run: | | |
cd ./yatori-go/yatori-go-console | |
go mod tidy | |
# 构建项目 | |
- name: Build project | |
run: | | |
cd ./yatori-go/yatori-go-console | |
go build -o yatori-go-console | |
# 上传二进制文件作为 Artifact | |
- name: Upload binary | |
uses: actions/upload-artifact@v3 | |
with: | |
name: myapp-binary | |
path: ./yatori-go/yatori-go-console/yatori-go-console |