From 56d32fd1f46a2e30444ad33062cb61fd0408c479 Mon Sep 17 00:00:00 2001 From: Antonio Navarro Perez Date: Sun, 1 Nov 2020 17:24:08 +0100 Subject: [PATCH] Compile windows without cgo (#14) --- .github/workflows/build.yaml | 6 ++++++ Makefile | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 6fe6522..2d262b7 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -30,6 +30,7 @@ jobs: - job_name: windows_amd64 os: windows-latest go: '1.15.x' + cgo: '0' name: ${{ matrix.job_name }} runs-on: ${{ matrix.os }} @@ -45,6 +46,11 @@ jobs: stable: 'false' go-version: ${{ matrix.go }} + - name: Set environment variables + shell: bash + run: | + if [[ "${{ matrix.cgo }}" != "" ]]; then echo 'CGO_ENABLED=${{ matrix.cgo }}' >> $GITHUB_ENV ; fi + - name: Install Libraries on Linux shell: bash run: | diff --git a/Makefile b/Makefile index 622e8b8..65f1586 100644 --- a/Makefile +++ b/Makefile @@ -23,14 +23,14 @@ build: go-generate go-build ## test: execute all tests. test: - go test -v --race -coverprofile=coverage.out ./... + CGO_ENABLED=1 go test -v --race -coverprofile=coverage.out ./... ## cross-compile: compile for other platforms using xgo. cross-compile: go-generate go-cross-compile go-build: @echo " > Building binary..." - go build -o bin/distribyted-$(VERSION)-`go env GOOS`-`go env GOARCH``go env GOEXE` -tags "release" cmd/distribyted/main.go + go build -o bin/distribyted-$(VERSION)-`go env GOOS`-`go env GOARCH``go env GOEXE` -tags "release" -ldflags='$(LDFLAGS)' cmd/distribyted/main.go go-generate: @echo " > Generating code files..."