1
0
woodpecker-yc-autoscaler/.ci/envsh.build
2024-07-30 00:54:43 +03:00

45 lines
1.1 KiB
Bash

#!/bin/sh
# SPDX-License-Identifier: Apache-2.0
# (c) 2024, Konstantin Demin
set -ef
unset GOAMD64 GOARM GOPPC64 GOMIPS GOMIPS64
## produce GOOS and GOARCH from TARGET_PLATFORM
unset GOOS GOARCH _variant
IFS=/ read -r GOOS GOARCH _variant <<-EOF
${TARGET_PLATFORM:?}
EOF
## verify that GOOS and GOARCH are not empty
: "${GOOS:?}" "${GOARCH:?}"
export GOOS GOARCH
## fill env with Go-related variables
if [ -n "${_variant}" ] ; then
case "${GOARCH}" in
amd64 )
export GOAMD64="${_variant}" ;;
arm )
export GOARM="${_variant#v}" ;;
ppc64 | ppc64le )
export GOPPC64="${_variant}" ;;
mips | mipsle )
export GOMIPS="${_variant}" ;;
mips64 | mips64le )
export GOMIPS64="${_variant}" ;;
esac
fi
unset _variant
unset RELMODE
while : ; do
[ -n "${CI_COMMIT_BRANCH}" ] || break
[ -n "${CI_REPO_DEFAULT_BRANCH}" ] || break
## RELMODE is for default branch only
[ "${CI_COMMIT_BRANCH}" = "${CI_REPO_DEFAULT_BRANCH}" ] || break
export RELMODE=1
break
done
[ -z "${CI_COMMIT_TAG}" ] || export RELMODE=1