From 8676f796ccba0d44a0df9c87d1c356c0f9ad9d6f Mon Sep 17 00:00:00 2001 From: "Tais P. Hansen" Date: Tue, 2 Nov 2021 23:49:39 +0100 Subject: [PATCH] Add platform builds --- .github/workflows/release.yaml | 7 +++++++ Makefile | 2 ++ scripts/build.sh | 8 +++++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 695d96c..7866683 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -8,6 +8,12 @@ on: jobs: build: runs-on: ubuntu-20.04 + + strategy: + fail-fast: true + matrix: + platform: [amd64] + steps: - uses: actions/checkout@v2 @@ -20,6 +26,7 @@ jobs: run: make probe env: BUILD_VARIANT: release + BUILD_PLATFORM: ${{ matrix.platform }} - name: Create Release id: create_release diff --git a/Makefile b/Makefile index b5837c6..38cf03b 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ +export BUILD_ARCH export BUILD_BRANCH_NAME := $(or $(BUILD_BRANCH_NAME),$(shell git symbolic-ref --short HEAD 2>/dev/null)) export BUILD_ID +export BUILD_OS := $(or $(BUILD_OS),$(if $(words $(eq $(subst -, ,$(BUILD_VARIANT))),3), $(word 1,$(words $(subst -, ,$(BUILD_VARIANT)))))) export BUILD_REPO_NAME export BUILD_REVISION_ID export BUILD_SHORT_SHA := $(or $(BUILD_SHORT_SHA),$(shell git describe --match="" --always --abbrev --dirty 2>/dev/null)) diff --git a/scripts/build.sh b/scripts/build.sh index 14a9ece..69c5758 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -5,7 +5,7 @@ set -euo pipefail function buildRelease { for target in "$@"; do set -x - CGO_ENABLED=0 GOOS=linux go build -v \ + CGO_ENABLED=0 GOOS=${build_os} GOARCH=${build_arch} go build -v \ -ldflags='-s -w -extldflags "-static" -X github.com/taisph/go_common/pkg/commonlog.BasePath='${base_path}/' -X github.com/taisph/go_common/pkg/commonversion.Version='${version}' -X github.com/taisph/go_common/pkg/commonversion.Branch='${branch_name}'' \ -o ${build_output}/${target##*/} ${target} set +x @@ -15,7 +15,7 @@ function buildRelease { function buildDebug { for target in "$@"; do set -x - CGO_ENABLED=0 GOOS=linux go build -v \ + CGO_ENABLED=0 GOOS=${build_os:-$(go env GOOS)} GOARCH=${build_arch:-$(go env GOARCH)} go build -v \ -ldflags='-extldflags "-static" -X github.com/taisph/go_common/pkg/commonlog.BasePath='${base_path}/' -X github.com/taisph/go_common/pkg/commonversion.Version='${version}' -X github.com/taisph/go_common/pkg/commonversion.Branch='${branch_name}'' \ -o ${build_output}/${target##*/} ${target} set +x @@ -25,8 +25,10 @@ function buildDebug { base_path="$(CDPATH="" cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" version=${BUILD_VERSION} branch_name=${BUILD_BRANCH_NAME} -build_variant=${BUILD_VARIANT} +build_arch=${BUILD_ARCH:-} +build_os=${BUILD_OS:-} build_output=out +build_variant=${BUILD_VARIANT} targets="$*" # Sanity checks.