@@ -0,0 +1,61 @@
|
||||
name: build
|
||||
|
||||
# 触发:主干推送、版本标签、PR、手动执行
|
||||
on:
|
||||
push:
|
||||
branches: [main, master]
|
||||
tags: ['v*']
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
# 纯 Go 依赖,交叉编译不需要 CGO
|
||||
CGO_ENABLED: "0"
|
||||
# 国内网络更稳的模块代理;如需官方源可改为 https://proxy.golang.org,direct
|
||||
GOPROXY: https://goproxy.cn,direct
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: build-and-test
|
||||
# 编译环境标签
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 20
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
cache: false
|
||||
|
||||
- name: Go version
|
||||
run: go version
|
||||
|
||||
- name: Vet
|
||||
run: go vet ./...
|
||||
|
||||
- name: Test
|
||||
run: go test ./...
|
||||
|
||||
- name: Build binaries
|
||||
run: |
|
||||
set -eu
|
||||
mkdir -p dist
|
||||
GOOS=windows GOARCH=amd64 go build -trimpath -ldflags "-s -w" -o dist/daili-windows-amd64.exe .
|
||||
GOOS=linux GOARCH=amd64 go build -trimpath -ldflags "-s -w" -o dist/daili-linux-amd64 .
|
||||
cd dist
|
||||
sha256sum daili-* > SHA256SUMS.txt
|
||||
ls -lh
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
env:
|
||||
ACTIONS_RESULTS_URL: https://git.code.cq.cn/
|
||||
with:
|
||||
name: subtrack-${{ github.run_number }}
|
||||
path: dist/
|
||||
if-no-files-found: error
|
||||
retention-days: 14
|
||||
Reference in New Issue
Block a user