添加工作流

This commit is contained in:
小贺
2025-10-19 18:42:06 +08:00
parent 4e2d95fcf6
commit aa7d445477
2 changed files with 44 additions and 0 deletions

0
.gitea/workflow/ci.yml Normal file
View File

View File

@@ -0,0 +1,44 @@
name: Release Cross-Compile
on:
push:
tags:
- 'v*' # 例如 v1.0.0
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
goos: [linux, windows, darwin]
goarch: [amd64]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22.x'
- uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ matrix.goos }}-${{ matrix.goarch }}
- run: go mod download
- name: Build
env:
CGO_ENABLED: "0"
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
mkdir -p dist/${GOOS}-${GOARCH}
BIN="yourapp"
OUT="dist/${GOOS}-${GOARCH}/${BIN}"
if [ "${GOOS}" = "windows" ]; then OUT="${OUT}.exe"; fi
go build -trimpath -ldflags="-s -w" -o "${OUT}" ./cmd/app
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: yourapp-${{ github.ref_name }}-${{ matrix.goos }}-${{ matrix.goarch }}
path: dist/${{ matrix.goos }}-${{ matrix.goarch }}/*