|
|
@@ -27,24 +27,49 @@ jobs:
|
|
27
|
27
|
uses: actions/setup-go@v4
|
|
28
|
28
|
with:
|
|
29
|
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
|
33
|
- name: tidy
|
|
34
|
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
|
41
|
- name: Build for ${{ matrix.goos }}-${{ matrix.goarch }}
|
|
37
|
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
|
49
|
if [ "${{ matrix.goos }}" = "windows" ]; then
|
|
39
|
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
|
52
|
else
|
|
41
|
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
|
55
|
fi
|
|
43
|
56
|
|
|
44
|
57
|
- name: Upload artifact
|
|
45
|
|
- uses: actions/upload-artifact@v3
|
|
|
58
|
+ uses: actions/upload-artifact@v4
|
|
46
|
59
|
with:
|
|
47
|
60
|
name: myapp-${{ matrix.goos }}-${{ matrix.goarch }}
|
|
48
|
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 }}
|