From 479bf2c7c5355e2b39f04617d6bad9945e45d271 Mon Sep 17 00:00:00 2001 From: ourines Date: Tue, 10 Feb 2026 15:04:48 +0800 Subject: [PATCH] fix: set GOOS/GOARCH in release workflow for correct cross-compilation Release binaries had mismatched architectures because go build used the runner's native arch instead of the target arch from the matrix. Add GOOS, GOARCH and CGO_ENABLED=0 env vars to the build step, and skip tests for cross-compiled binaries that can't run on the runner. Closes #3 --- .github/workflows/release.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bada462..3339e6a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,21 +14,27 @@ jobs: - platform: ubuntu-latest goos: linux goarch: amd64 + can_test: true - platform: ubuntu-latest goos: linux goarch: arm64 + can_test: false - platform: windows-latest goos: windows goarch: amd64 + can_test: true - platform: windows-latest goos: windows goarch: arm64 + can_test: false - platform: macos-latest goos: darwin goarch: amd64 + can_test: false - platform: macos-latest goos: darwin goarch: arm64 + can_test: true runs-on: ${{ matrix.platform }} @@ -47,6 +53,10 @@ jobs: - name: Build codes shell: bash + env: + GOOS: ${{ matrix.goos }} + GOARCH: ${{ matrix.goarch }} + CGO_ENABLED: '0' run: | if [ "${{ matrix.goos }}" = "windows" ]; then go build -o codes.exe ./cmd/codes @@ -55,6 +65,7 @@ jobs: fi - name: Test + if: matrix.can_test shell: bash run: | if [ "${{ matrix.goos }}" = "windows" ]; then