Files
runlike-go/.gitea/workflows/ci.yml
小贺 c1c19c09a6
All checks were successful
CI Cross-Compile / build (amd64, darwin) (push) Successful in 34s
CI Cross-Compile / build (amd64, linux) (push) Successful in 23s
CI Cross-Compile / build (amd64, windows) (push) Successful in 23s
修改upload版本
2025-10-19 18:59:32 +08:00

60 lines
1.6 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: CI Cross-Compile
on:
push:
branches: [ main ]
pull_request:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
goos: [linux, windows, darwin]
goarch: [amd64]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22.x'
- name: Cache Go build/mod
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ matrix.goos }}-${{ matrix.goarch }}
restore-keys: |
${{ runner.os }}-go-
- name: Download deps
run: go mod download
- name: Cross-compile (${{ matrix.goos }}/${{ matrix.goarch }})
env:
CGO_ENABLED: "0" # 关闭 cgo便于纯交叉构建
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
mkdir -p dist/${GOOS}-${GOARCH}
OUT="dist/${GOOS}-${GOARCH}/app"
if [ "${GOOS}" = "windows" ]; then OUT="${OUT}.exe"; fi
# -trimpath/-ldflags 让产物更小更可复现;按你的入口调整 ./
go build -trimpath -ldflags="-s -w" -o "${OUT}" ./
echo "Built ${OUT}"
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: app-${{ matrix.goos }}-${{ matrix.goarch }}
path: dist/${{ matrix.goos }}-${{ matrix.goarch }}/*
if-no-files-found: error