From 071c7b3c0e2c89f9d933ba69a1dd1ee1e0e5ea52 Mon Sep 17 00:00:00 2001 From: Kazuyoshi Kato Date: Wed, 27 Oct 2021 11:20:23 -0700 Subject: [PATCH 1/2] Surface any failures from shell scripts This change fixes #297. Signed-off-by: Kazuyoshi Kato --- scripts/build_binary.sh | 4 +++- scripts/build_variant.sh | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/build_binary.sh b/scripts/build_binary.sh index e1c673e5..4235b5d1 100755 --- a/scripts/build_binary.sh +++ b/scripts/build_binary.sh @@ -12,6 +12,8 @@ # ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. +set -euo pipefail + # Normalize to working directory being build root (up one level from ./scripts) ROOT=$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd ) cd "${ROOT}" @@ -32,7 +34,7 @@ if [[ -n "${3}" ]]; then version_ldflags="$version_ldflags -X ${package_root}/version.GitCommitSHA=${3}" fi -GOOS=$TARGET_GOOS GOARCH=$TARGET_GOARCH CGO_ENABLED=0 \ +GOOS=${TARGET_GOOS:-} GOARCH=${TARGET_GOARCH:-} CGO_ENABLED=0 \ go build -installsuffix cgo -a -ldflags "-s ${version_ldflags}" \ -o ../$1/docker-credential-ecr-login \ ./cli/docker-credential-ecr-login diff --git a/scripts/build_variant.sh b/scripts/build_variant.sh index bbb5d978..c17beefb 100755 --- a/scripts/build_variant.sh +++ b/scripts/build_variant.sh @@ -12,6 +12,8 @@ # ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. +set -euo pipefail + # This script is used for compilation of a specific variant. # Specify GOOS as $1, GOARCH as $2 # Binaries are placed into ./bin/$GOOS-$GOARCH/docker-credential-ecr-login From e61bf250eb598660d9b15cb73a057dea756c30c6 Mon Sep 17 00:00:00 2001 From: Kazuyoshi Kato Date: Wed, 27 Oct 2021 11:41:39 -0700 Subject: [PATCH 2/2] Run "make all-variants" only if Go >= 1.16 all-variants now compile the helper for Apple Silicon. However the architecture is only supported by Go >= 1.16. Instead of dropping older Go versions, this change runs "make all-variants" only if Go >= 1.16. Signed-off-by: Kazuyoshi Kato --- .github/workflows/build.yaml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index cbd9e63f..15077766 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -27,5 +27,14 @@ jobs: with: go-version: ${{ matrix.go }} - run: make get-deps - - run: make all-variants + + # Apple Silicon is not supported by Go < 1.16. + # https://go.dev/blog/go1.16 + - name: Cross-compile all variants + run: make all-variants + if: ${{ matrix.go >= '1.16' }} + - name: Cross-compile all variants except for Apple Silicon + run: make linux-amd64 linux-arm64 darwin-amd64 windows-amd64 + if: ${{ matrix.go < '1.16' }} + - run: make test