From 23329cfde43eb50e564c7ad6339d7f5467b4cc8d Mon Sep 17 00:00:00 2001 From: Ryan SIU Date: Sun, 19 Apr 2020 20:45:00 +0800 Subject: [PATCH 1/6] Add a cross compiling test in master --- .github/workflows/binary.yml | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/binary.yml diff --git a/.github/workflows/binary.yml b/.github/workflows/binary.yml new file mode 100644 index 0000000..3173318 --- /dev/null +++ b/.github/workflows/binary.yml @@ -0,0 +1,37 @@ +name: Go +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] +jobs: + build: + name: Build + strategy: + matrix: + operating-system: + - linux + - darwin + - windows + arch: + - '386' + - 'amd64' + runs-on: ubuntu-latest + steps: + - name: Set up Go ${{ matrix.go-versions }} + uses: actions/setup-go@v1 + with: + go-version: 1.14 + id: go + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + - name: Get dependencies + run: | + go get -v -t -d ./... + - name: Build Artifacts + run: | + go build -ldflags="-s -w" + env: + CGO_ENABLED: "1" + GOOS: ${{ matrix.operating-system }} + GOARCH: ${{ matrix.arch }} From 3c3c366576b78b3679b27abae9318b775372d081 Mon Sep 17 00:00:00 2001 From: Ryan SIU Date: Sun, 19 Apr 2020 20:47:01 +0800 Subject: [PATCH 2/6] Install 32 bits libraries --- .github/workflows/binary.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/binary.yml b/.github/workflows/binary.yml index 3173318..f07316d 100644 --- a/.github/workflows/binary.yml +++ b/.github/workflows/binary.yml @@ -1,4 +1,4 @@ -name: Go +name: Binary on: push: branches: [ master ] @@ -25,6 +25,10 @@ jobs: id: go - name: Check out code into the Go module directory uses: actions/checkout@v2 + - name: Install 32 bits libaries + if: ${{ matrix.arch }} == '386' + run: | + apt-get update && apt-get install gcc-multilib -y -q - name: Get dependencies run: | go get -v -t -d ./... From dac650167ed9d7a83da1142d22e87024247f8340 Mon Sep 17 00:00:00 2001 From: Ryan SIU Date: Sun, 19 Apr 2020 20:49:22 +0800 Subject: [PATCH 3/6] Add the sudo to install the software --- .github/workflows/binary.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/binary.yml b/.github/workflows/binary.yml index f07316d..c709b16 100644 --- a/.github/workflows/binary.yml +++ b/.github/workflows/binary.yml @@ -28,7 +28,7 @@ jobs: - name: Install 32 bits libaries if: ${{ matrix.arch }} == '386' run: | - apt-get update && apt-get install gcc-multilib -y -q + sudo apt-get update && sudo apt-get install gcc-multilib -y -q - name: Get dependencies run: | go get -v -t -d ./... From 42716a0b46130ce0202e46d58cd30242cb2ef606 Mon Sep 17 00:00:00 2001 From: Ryan SIU Date: Sun, 19 Apr 2020 20:57:25 +0800 Subject: [PATCH 4/6] Fix the windows 32bit cross compiling --- .github/workflows/binary.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/binary.yml b/.github/workflows/binary.yml index c709b16..145c50a 100644 --- a/.github/workflows/binary.yml +++ b/.github/workflows/binary.yml @@ -29,10 +29,25 @@ jobs: if: ${{ matrix.arch }} == '386' run: | sudo apt-get update && sudo apt-get install gcc-multilib -y -q + - name: Install 32 bits libraries for Windows + if: ${{ matrix.arch }} == '386' && ${{ matrix.windows }} == 'windows' + run: + sudo apt-get update && sudo apt-get install gcc-mingw-w64 -y -q - name: Get dependencies run: | go get -v -t -d ./... + - name: Build Artifacts for 32bits Windows + if: ${{ matrix.arch }} == '386' && ${{ matrix.windows }} == 'windows' + run: | + go build -ldflags="-s -w" + env: + CGO_ENABLED: "1" + GOOS: ${{ matrix.operating-system }} + GOARCH: ${{ matrix.arch }} + CXX_FOR_TARGET: i686-w64-mingw32-g++ + CC_FOR_TARGET: i686-w64-mingw32-gcc - name: Build Artifacts + if: ${{ matrix.arch }} != '386' && ${{ matrix.windows }} != 'windows' run: | go build -ldflags="-s -w" env: From a261858782d8871dfe7f1aad628e0863ec79ebd2 Mon Sep 17 00:00:00 2001 From: Ryan SIU Date: Sun, 19 Apr 2020 21:06:01 +0800 Subject: [PATCH 5/6] Remove windows building for the time being --- .github/workflows/binary.yml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/.github/workflows/binary.yml b/.github/workflows/binary.yml index 145c50a..2c3bf8b 100644 --- a/.github/workflows/binary.yml +++ b/.github/workflows/binary.yml @@ -12,7 +12,6 @@ jobs: operating-system: - linux - darwin - - windows arch: - '386' - 'amd64' @@ -29,25 +28,10 @@ jobs: if: ${{ matrix.arch }} == '386' run: | sudo apt-get update && sudo apt-get install gcc-multilib -y -q - - name: Install 32 bits libraries for Windows - if: ${{ matrix.arch }} == '386' && ${{ matrix.windows }} == 'windows' - run: - sudo apt-get update && sudo apt-get install gcc-mingw-w64 -y -q - name: Get dependencies run: | go get -v -t -d ./... - - name: Build Artifacts for 32bits Windows - if: ${{ matrix.arch }} == '386' && ${{ matrix.windows }} == 'windows' - run: | - go build -ldflags="-s -w" - env: - CGO_ENABLED: "1" - GOOS: ${{ matrix.operating-system }} - GOARCH: ${{ matrix.arch }} - CXX_FOR_TARGET: i686-w64-mingw32-g++ - CC_FOR_TARGET: i686-w64-mingw32-gcc - name: Build Artifacts - if: ${{ matrix.arch }} != '386' && ${{ matrix.windows }} != 'windows' run: | go build -ldflags="-s -w" env: From d96ff4e9363e77de898004642276636889b6961c Mon Sep 17 00:00:00 2001 From: Ryan SIU Date: Sun, 19 Apr 2020 21:23:25 +0800 Subject: [PATCH 6/6] Use windows VM to build the binary --- .github/workflows/binary.yml | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/.github/workflows/binary.yml b/.github/workflows/binary.yml index 2c3bf8b..86e7628 100644 --- a/.github/workflows/binary.yml +++ b/.github/workflows/binary.yml @@ -5,13 +5,12 @@ on: pull_request: branches: [ master ] jobs: - build: + linux: name: Build strategy: matrix: operating-system: - linux - - darwin arch: - '386' - 'amd64' @@ -38,3 +37,31 @@ jobs: CGO_ENABLED: "1" GOOS: ${{ matrix.operating-system }} GOARCH: ${{ matrix.arch }} + windows: + name: Build + strategy: + matrix: + operating-system: + - windows + arch: + - '386' + - 'amd64' + runs-on: windows-latest + steps: + - name: Set up Go ${{ matrix.go-versions }} + uses: actions/setup-go@v1 + with: + go-version: 1.14 + id: go + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + - name: Get dependencies + run: | + go get -v -t -d ./... + - name: Build Artifacts + run: | + go build -ldflags="-s -w" + env: + CGO_ENABLED: "1" + GOOS: ${{ matrix.operating-system }} + GOARCH: ${{ matrix.arch }}