|
@@ -18,7 +18,7 @@ on:
|
|
- master
|
|
- master
|
|
|
|
|
|
jobs:
|
|
jobs:
|
|
- test:
|
|
|
|
|
|
+ test-ubuntu:
|
|
runs-on: ubuntu-latest
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
steps:
|
|
- name: Checkout code
|
|
- name: Checkout code
|
|
@@ -38,10 +38,30 @@ jobs:
|
|
- name: Test
|
|
- name: Test
|
|
run: GOOS=linux GOARCH=amd64 go test ./...
|
|
run: GOOS=linux GOARCH=amd64 go test ./...
|
|
|
|
|
|
- build:
|
|
|
|
|
|
+ test-windows:
|
|
|
|
+ runs-on: windows-latest
|
|
|
|
+ steps:
|
|
|
|
+ - name: Checkout code
|
|
|
|
+ uses: actions/checkout@v4
|
|
|
|
+
|
|
|
|
+ - name: Set up Go
|
|
|
|
+ uses: actions/setup-go@v5
|
|
|
|
+ with:
|
|
|
|
+ go-version: '1.23.4' # 根据需要指定Go版本
|
|
|
|
+
|
|
|
|
+ - name: Download module
|
|
|
|
+ run: GOOS=windows GOARCH=amd64 go mod tidy
|
|
|
|
+
|
|
|
|
+ - name: Go generate
|
|
|
|
+ run: GOOS=windows GOARCH=amd64 go generate ./...
|
|
|
|
+
|
|
|
|
+ - name: Test
|
|
|
|
+ run: GOOS=windows GOARCH=amd64 go test ./...
|
|
|
|
+
|
|
|
|
+ build-ubuntu:
|
|
runs-on: ubuntu-latest
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
needs:
|
|
- - test
|
|
|
|
|
|
+ - test-ubuntu
|
|
|
|
|
|
steps:
|
|
steps:
|
|
- name: Checkout code
|
|
- name: Checkout code
|
|
@@ -74,17 +94,61 @@ jobs:
|
|
run: |
|
|
run: |
|
|
ls -l "${{ github.workspace }}/output"
|
|
ls -l "${{ github.workspace }}/output"
|
|
|
|
|
|
- - name: Upload artifact
|
|
|
|
|
|
+ - name: Upload ubuntu artifact
|
|
uses: actions/upload-artifact@v4
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
with:
|
|
name: linux_amd64_executable_files
|
|
name: linux_amd64_executable_files
|
|
path: "${{ github.workspace }}/output/"
|
|
path: "${{ github.workspace }}/output/"
|
|
if-no-files-found: error
|
|
if-no-files-found: error
|
|
|
|
|
|
|
|
+ build-windows:
|
|
|
|
+ runs-on: windows-latest
|
|
|
|
+ needs:
|
|
|
|
+ - test-windows
|
|
|
|
+
|
|
|
|
+ steps:
|
|
|
|
+ - name: Checkout code
|
|
|
|
+ uses: actions/checkout@v4
|
|
|
|
+
|
|
|
|
+ - name: Set up Go
|
|
|
|
+ uses: actions/setup-go@v5
|
|
|
|
+ with:
|
|
|
|
+ go-version: '1.23.4' # 根据需要指定Go版本
|
|
|
|
+
|
|
|
|
+ - name: Download module
|
|
|
|
+ run: GOOS=windows GOARCH=amd64 go mod tidy
|
|
|
|
+
|
|
|
|
+ - name: Go generate
|
|
|
|
+ run: GOOS=windows GOARCH=amd64 go generate ./...
|
|
|
|
+
|
|
|
|
+ - name: Build lionv1
|
|
|
|
+ run: |
|
|
|
|
+ GOOS=windows GOARCH=amd64 go build -o "${{ github.workspace }}/output/windows_amd64_lionv1.exe" -trimpath -ldflags='-s -w -extldflags "-static"' github.com/SongZihuan/BackendServerTemplate/src/cmd/lionv1
|
|
|
|
+
|
|
|
|
+ - name: Build tigerv1
|
|
|
|
+ run: |
|
|
|
|
+ GOOS=windows GOARCH=amd64 go build -o "${{ github.workspace }}/output/windows_amd64_tigerv1.exe" -trimpath -ldflags='-s -w -extldflags "-static"' github.com/SongZihuan/BackendServerTemplate/src/cmd/tigerv1
|
|
|
|
+
|
|
|
|
+ - name: Build catv1
|
|
|
|
+ run: |
|
|
|
|
+ GOOS=windows GOARCH=amd64 go build -o "${{ github.workspace }}/output/windows_amd64_catv1.exe" -trimpath -ldflags='-s -w -extldflags "-static"' github.com/SongZihuan/BackendServerTemplate/src/cmd/catv1
|
|
|
|
+
|
|
|
|
+ - name: List build directory
|
|
|
|
+ run: |
|
|
|
|
+ ls -l "${{ github.workspace }}/output"
|
|
|
|
+
|
|
|
|
+ - name: Upload windows artifact
|
|
|
|
+ uses: actions/upload-artifact@v4
|
|
|
|
+ with:
|
|
|
|
+ name: windows_amd64_executable_files
|
|
|
|
+ path: "${{ github.workspace }}/output/"
|
|
|
|
+ if-no-files-found: error
|
|
|
|
+
|
|
create_release:
|
|
create_release:
|
|
runs-on: ubuntu-latest
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
needs:
|
|
- - build
|
|
|
|
|
|
+ - build-ubuntu
|
|
|
|
+ - build-windows
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
|
|
|
|
steps:
|
|
steps:
|
|
@@ -100,12 +164,18 @@ jobs:
|
|
TAG_NAME=$(echo "${GITHUB_REF}" | sed 's/refs\/tags\///')
|
|
TAG_NAME=$(echo "${GITHUB_REF}" | sed 's/refs\/tags\///')
|
|
echo "tag=${TAG_NAME}" >> $GITHUB_OUTPUT
|
|
echo "tag=${TAG_NAME}" >> $GITHUB_OUTPUT
|
|
|
|
|
|
- - name: Download artifact
|
|
|
|
|
|
+ - name: Download ubuntu artifact
|
|
uses: actions/download-artifact@v4
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
with:
|
|
name: linux_amd64_executable_files
|
|
name: linux_amd64_executable_files
|
|
path: ${{ github.workspace }}/output
|
|
path: ${{ github.workspace }}/output
|
|
|
|
|
|
|
|
+ - name: Download windows artifact
|
|
|
|
+ uses: actions/download-artifact@v4
|
|
|
|
+ with:
|
|
|
|
+ name: windows_amd64_executable_files
|
|
|
|
+ path: ${{ github.workspace }}/output
|
|
|
|
+
|
|
- name: List directory
|
|
- name: List directory
|
|
run: ls -l ${{ github.workspace }}/output
|
|
run: ls -l ${{ github.workspace }}/output
|
|
|
|
|
|
@@ -113,7 +183,7 @@ jobs:
|
|
id: create_release
|
|
id: create_release
|
|
uses: ncipollo/release-action@v1
|
|
uses: ncipollo/release-action@v1
|
|
with:
|
|
with:
|
|
- artifacts: "${{ github.workspace }}/output/linux_amd64_lionv1,${{ github.workspace }}/output/linux_amd64_tigerv1,${{ github.workspace }}/output/linux_amd64_catv1"
|
|
|
|
|
|
+ artifacts: "${{ github.workspace }}/output/linux_amd64_lionv1,${{ github.workspace }}/output/linux_amd64_tigerv1,${{ github.workspace }}/output/linux_amd64_catv1,${{ github.workspace }}/output/windows_amd64_lionv1.exe,${{ github.workspace }}/output/windows_amd64_tigerv1.exe,${{ github.workspace }}/output/windows_amd64_catv1.exe"
|
|
artifactErrorsFailBuild: true
|
|
artifactErrorsFailBuild: true
|
|
allowUpdates: false
|
|
allowUpdates: false
|
|
body: |
|
|
body: |
|