Browse Source

up test.yml

ljw 1 year ago
parent
commit
192b3b11a9
1 changed files with 30 additions and 5 deletions
  1. 30 5
      .github/workflows/test.yml

+ 30 - 5
.github/workflows/test.yml

@@ -27,24 +27,49 @@ jobs:
27
         uses: actions/setup-go@v4
27
         uses: actions/setup-go@v4
28
         with:
28
         with:
29
           go-version: '1.22'  # 选择 Go 版本
29
           go-version: '1.22'  # 选择 Go 版本
30
-      - name: install gcc
31
-        run: sudo apt-get install gcc-mingw-w64-x86-64
30
+      - name: install gcc zip
31
+        run: sudo apt-get install gcc-mingw-w64-x86-64 zip -y
32
 
32
 
33
       - name: tidy
33
       - name: tidy
34
         run: go mod tidy
34
         run: go mod tidy
35
+      - name: swag
36
+        run: |
37
+          go install github.com/swaggo/swag/cmd/swag@latest
38
+          swag init -g cmd/apimain.go --output docs/api --instanceName api --exclude http/controller/admin
39
+          swag init -g cmd/apimain.go --output docs/admin --instanceName admin --exclude http/controller/api
35
 
40
 
36
       - name: Build for ${{ matrix.goos }}-${{ matrix.goarch }}
41
       - name: Build for ${{ matrix.goos }}-${{ matrix.goarch }}
37
         run: |
42
         run: |
43
+          mkdir release -p
44
+          cp -ar resources release/
45
+          cp -ar docs release/
46
+          cp -ar conf release/
47
+          mkdir -p release/data
48
+          mkdir -p release/runtime
38
           if [ "${{ matrix.goos }}" = "windows" ]; then
49
           if [ "${{ matrix.goos }}" = "windows" ]; then
39
             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
40
           else
52
           else
41
             GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} CGO_ENABLED=1 go build -ldflags "-s -w" -o ./release/apimain ./cmd/apimain.go
53
             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
42
           fi
55
           fi
43
 
56
 
44
       - name: Upload artifact
57
       - name: Upload artifact
45
-        uses: actions/upload-artifact@v3
58
+        uses: actions/upload-artifact@v4
46
         with:
59
         with:
47
           name: myapp-${{ matrix.goos }}-${{ matrix.goarch }}
60
           name: myapp-${{ matrix.goos }}-${{ matrix.goarch }}
48
           path: |
61
           path: |
49
-            release/apimain
50
-            release/apimain.exe
62
+            ${{ matrix.goos}}-${{ matrix.goarch }}.tar.gz
63
+            ${{ matrix.goos}}-${{ matrix.goarch }}.zip
64
+  release:
65
+    runs-on: ubuntu-latest
66
+    needs: build
67
+    steps:
68
+      - name: Create GitHub Release
69
+        uses: softprops/action-gh-release@v2
70
+        with:
71
+          files: |
72
+            ${{ matrix.goos}}-${{ matrix.goarch }}.tar.gz
73
+            ${{ matrix.goos}}-${{ matrix.goarch }}.zip
74
+        env:
75
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}