diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7ab82bc94b..c13f2eeb9b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,7 +30,7 @@ jobs: v: true x: false race: false - ldflags: -s -w -X github.com/naiba/nezha/service/singleton.Version=${{ steps.extract_branch.outputs.tag }} + ldflags: -s -w --extldflags '-static -fpic' -X github.com/naiba/nezha/service/singleton.Version=${{ steps.extract_branch.outputs.tag }} buildmode: default - name: fix dist diff --git a/.github/workflows/test-on-pr.yml b/.github/workflows/test-on-pr.yml index 79a9682d4a..bed02be7dd 100644 --- a/.github/workflows/test-on-pr.yml +++ b/.github/workflows/test-on-pr.yml @@ -17,10 +17,22 @@ jobs: - name: Unit test run: | go test -v ./... - - name: Build test - run: | - go build cmd/dashboard/main.go - name: Run Gosec Security Scanner uses: securego/gosec@master with: args: --exclude=G104,G402 ./... + - name: xgo build + uses: crazy-max/ghaction-xgo@v2 + with: + xgo_version: latest + go_version: 1.21 + dest: dist + pkg: cmd/dashboard + prefix: dashboard + targets: linux/amd64,linux/arm64,linux/arm-7,linux/s390x,linux/riscv64 # linux/386, + v: true + x: false + race: false + ldflags: -s -w --extldflags '-static -fpic' -X github.com/naiba/nezha/service/singleton.Version=test + buildmode: default + diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dbf9aff817..98578957d2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,10 +26,21 @@ jobs: - name: Unit test run: | go test -v ./... - - name: Build test - run: | - go build cmd/dashboard/main.go - name: Run Gosec Security Scanner uses: securego/gosec@master with: args: --exclude=G104,G402 ./... + - name: xgo build + uses: crazy-max/ghaction-xgo@v2 + with: + xgo_version: latest + go_version: 1.21 + dest: dist + pkg: cmd/dashboard + prefix: dashboard + targets: linux/amd64,linux/arm64,linux/arm-7,linux/s390x,linux/riscv64 # linux/386, + v: true + x: false + race: false + ldflags: -s -w --extldflags '-static -fpic' -X github.com/naiba/nezha/service/singleton.Version=test + buildmode: default