添加工作流
This commit is contained in:
0
.gitea/workflow/ci.yml
Normal file
0
.gitea/workflow/ci.yml
Normal file
44
.gitea/workflow/release.yml
Normal file
44
.gitea/workflow/release.yml
Normal 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 }}/*
|
||||||
Reference in New Issue
Block a user