Files
runlike-go/.gitea/workflow/release.yml
2025-10-19 18:42:06 +08:00

45 lines
1.2 KiB
YAML

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 }}/*