up test.yml

This commit is contained in:
ljw
2024-09-22 20:30:12 +08:00
parent 192b3b11a9
commit d394931fce

View File

@@ -1,14 +1,14 @@
name: Go Build and Release
#on:
# push:
# tags:
# - 'v*.*.*' # 当推送带有版本号的 tag例如 v1.0.0)时触发工作流
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
tags:
- 'v*.*.*' # 当推送带有版本号的 tag例如 v1.0.0)时触发工作流
#on:
# push:
# branches: [ "master" ]
# pull_request:
# branches: [ "master" ]
jobs:
build:
@@ -48,10 +48,11 @@ 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
zip -r ${{ matrix.goos}}-${{ matrix.goarch }}.zip ./release
cd release
zip -r ../${{ matrix.goos}}-${{ matrix.goarch }}.zip .
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 ./release
tar -czf ${{ matrix.goos}}-${{ matrix.goarch }}.tar.gz -C ./release .
fi
- name: Upload artifact
@@ -67,6 +68,7 @@ jobs:
steps:
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
${{ matrix.goos}}-${{ matrix.goarch }}.tar.gz