up test.yml

This commit is contained in:
ljw
2024-09-22 21:40:17 +08:00
parent 758f1fb1c9
commit 601e1de3b3

View File

@@ -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