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 name: Go Build and Release
#on:
# push:
# tags:
# - 'v*.*.*' # 当推送带有版本号的 tag例如 v1.0.0)时触发工作流
on: on:
push: push:
branches: [ "master" ] tags:
pull_request: - 'v*.*.*' # 当推送带有版本号的 tag例如 v1.0.0)时触发工作流
branches: [ "master" ] #on:
# push:
# branches: [ "master" ]
# pull_request:
# branches: [ "master" ]
jobs: jobs:
build: build:
@@ -48,10 +48,11 @@ jobs:
mkdir -p release/runtime mkdir -p release/runtime
if [ "${{ matrix.goos }}" = "windows" ]; then 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 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 else
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} CGO_ENABLED=1 go build -ldflags "-s -w" -o ./release/apimain ./cmd/apimain.go 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 fi
- name: Upload artifact - name: Upload artifact
@@ -67,6 +68,7 @@ jobs:
steps: steps:
- name: Create GitHub Release - name: Create GitHub Release
uses: softprops/action-gh-release@v2 uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with: with:
files: | files: |
${{ matrix.goos}}-${{ matrix.goarch }}.tar.gz ${{ matrix.goos}}-${{ matrix.goarch }}.tar.gz