From 601e1de3b38e5c31cc00d3391a5fc9284a72dce7 Mon Sep 17 00:00:00 2001 From: ljw <84855512@qq.com> Date: Sun, 22 Sep 2024 21:40:17 +0800 Subject: [PATCH] up test.yml --- .github/workflows/test.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 31d8055..49538fe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,7 +28,10 @@ jobs: with: go-version: '1.22' # 选择 Go 版本 - name: install gcc zip - run: sudo apt-get install gcc-mingw-w64-x86-64 zip -y + run: | + if [ "${{ matrix.goos }}" = "windows" ]; then + sudo apt-get install gcc-mingw-w64-x86-64 zip -y + fi - name: tidy run: go mod tidy @@ -48,11 +51,10 @@ jobs: mkdir -p release/runtime if [ "${{ matrix.goos }}" = "windows" ]; then CC=x86_64-w64-mingw32-gcc GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} CGO_ENABLED=1 go build -o ./release/apimain.exe ./cmd/apimain.go - cd release - zip -r ../${{ matrix.goos}}-${{ matrix.goarch }}.zip . + zip -r ${{ matrix.goos}}-${{ matrix.goarch }}.zip ./release else - GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} CGO_ENABLED=1 go build -ldflags "-s -w" -o ./release/apimain ./cmd/apimain.go - tar -czf ${{ matrix.goos}}-${{ matrix.goarch }}.tar.gz -C ./release . + GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} CGO_LDFLAGS="-static" CGO_ENABLED=1 go build -ldflags "-s -w" -o ./release/apimain ./cmd/apimain.go + tar -czf ${{ matrix.goos}}-${{ matrix.goarch }}.tar.gz ./release fi - name: Upload artifact