ljw 1 год назад
Родитель
Сommit
d394931fce
1 измененных файлов с 11 добавлено и 9 удалено
  1. 11 9
      .github/workflows/test.yml

+ 11 - 9
.github/workflows/test.yml

@@ -1,14 +1,14 @@
1
 name: Go Build and Release
1
 name: Go Build and Release
2
 
2
 
3
-#on:
4
-#  push:
5
-#    tags:
6
-#      - 'v*.*.*'  # 当推送带有版本号的 tag(例如 v1.0.0)时触发工作流
7
 on:
3
 on:
8
   push:
4
   push:
9
-    branches: [ "master" ]
10
-  pull_request:
11
-    branches: [ "master" ]
5
+    tags:
6
+      - 'v*.*.*'  # 当推送带有版本号的 tag(例如 v1.0.0)时触发工作流
7
+#on:
8
+#  push:
9
+#    branches: [ "master" ]
10
+#  pull_request:
11
+#    branches: [ "master" ]
12
 
12
 
13
 jobs:
13
 jobs:
14
   build:
14
   build:
@@ -48,10 +48,11 @@ jobs:
48
           mkdir -p release/runtime
48
           mkdir -p release/runtime
49
           if [ "${{ matrix.goos }}" = "windows" ]; then
49
           if [ "${{ matrix.goos }}" = "windows" ]; then
50
             CC=x86_64-w64-mingw32-gcc GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} CGO_ENABLED=1 go build -o ./release/apimain.exe ./cmd/apimain.go
50
             CC=x86_64-w64-mingw32-gcc GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} CGO_ENABLED=1 go build -o ./release/apimain.exe ./cmd/apimain.go
51
-            zip -r ${{ matrix.goos}}-${{ matrix.goarch }}.zip ./release
51
+            cd release 
52
+            zip -r ../${{ matrix.goos}}-${{ matrix.goarch }}.zip .
52
           else
53
           else
53
             GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} CGO_ENABLED=1 go build -ldflags "-s -w" -o ./release/apimain ./cmd/apimain.go
54
             GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} CGO_ENABLED=1 go build -ldflags "-s -w" -o ./release/apimain ./cmd/apimain.go
54
-            tar -czf ${{ matrix.goos}}-${{ matrix.goarch }}.tar.gz ./release
55
+            tar -czf ${{ matrix.goos}}-${{ matrix.goarch }}.tar.gz -C ./release .
55
           fi
56
           fi
56
 
57
 
57
       - name: Upload artifact
58
       - name: Upload artifact
@@ -67,6 +68,7 @@ jobs:
67
     steps:
68
     steps:
68
       - name: Create GitHub Release
69
       - name: Create GitHub Release
69
         uses: softprops/action-gh-release@v2
70
         uses: softprops/action-gh-release@v2
71
+        if: startsWith(github.ref, 'refs/tags/')
70
         with:
72
         with:
71
           files: |
73
           files: |
72
             ${{ matrix.goos}}-${{ matrix.goarch }}.tar.gz
74
             ${{ matrix.goos}}-${{ matrix.goarch }}.tar.gz