up test.yml
This commit is contained in:
35
.github/workflows/test.yml
vendored
35
.github/workflows/test.yml
vendored
@@ -27,24 +27,49 @@ jobs:
|
|||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: '1.22' # 选择 Go 版本
|
go-version: '1.22' # 选择 Go 版本
|
||||||
- name: install gcc
|
- name: install gcc zip
|
||||||
run: sudo apt-get install gcc-mingw-w64-x86-64
|
run: sudo apt-get install gcc-mingw-w64-x86-64 zip -y
|
||||||
|
|
||||||
- name: tidy
|
- name: tidy
|
||||||
run: go mod tidy
|
run: go mod tidy
|
||||||
|
- name: swag
|
||||||
|
run: |
|
||||||
|
go install github.com/swaggo/swag/cmd/swag@latest
|
||||||
|
swag init -g cmd/apimain.go --output docs/api --instanceName api --exclude http/controller/admin
|
||||||
|
swag init -g cmd/apimain.go --output docs/admin --instanceName admin --exclude http/controller/api
|
||||||
|
|
||||||
- name: Build for ${{ matrix.goos }}-${{ matrix.goarch }}
|
- name: Build for ${{ matrix.goos }}-${{ matrix.goarch }}
|
||||||
run: |
|
run: |
|
||||||
|
mkdir release -p
|
||||||
|
cp -ar resources release/
|
||||||
|
cp -ar docs release/
|
||||||
|
cp -ar conf release/
|
||||||
|
mkdir -p release/data
|
||||||
|
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
|
||||||
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
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: myapp-${{ matrix.goos }}-${{ matrix.goarch }}
|
name: myapp-${{ matrix.goos }}-${{ matrix.goarch }}
|
||||||
path: |
|
path: |
|
||||||
release/apimain
|
${{ matrix.goos}}-${{ matrix.goarch }}.tar.gz
|
||||||
release/apimain.exe
|
${{ matrix.goos}}-${{ matrix.goarch }}.zip
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build
|
||||||
|
steps:
|
||||||
|
- name: Create GitHub Release
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
with:
|
||||||
|
files: |
|
||||||
|
${{ matrix.goos}}-${{ matrix.goarch }}.tar.gz
|
||||||
|
${{ matrix.goos}}-${{ matrix.goarch }}.zip
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
Reference in New Issue
Block a user