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