From aa7d445477a7d0142095d4b6e7b4c25d247fec45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=B4=BA?= Date: Sun, 19 Oct 2025 18:42:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=B7=A5=E4=BD=9C=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflow/ci.yml | 0 .gitea/workflow/release.yml | 44 +++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 .gitea/workflow/ci.yml create mode 100644 .gitea/workflow/release.yml diff --git a/.gitea/workflow/ci.yml b/.gitea/workflow/ci.yml new file mode 100644 index 0000000..e69de29 diff --git a/.gitea/workflow/release.yml b/.gitea/workflow/release.yml new file mode 100644 index 0000000..24aa688 --- /dev/null +++ b/.gitea/workflow/release.yml @@ -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 }}/*