Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(build): use goversion to pull correct toolchain image #248

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 56 additions & 43 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ direnv_version_major=$(direnv version | cut -d "." -f1 | tr -d '\n')
direnv_version_minor=$(direnv version | cut -d "." -f2 | tr -d '\n')

if [[ $direnv_version_major -lt 2 ]] || [[ $direnv_version_major -eq 2 ]] && [[ $direnv_version_minor -lt 32 ]]; then
echo -e "\033[31munsupported direnv version $(direnv version) < 2.32.x"
exit 1
echo -e "\033[31munsupported direnv version $(direnv version) < 2.32.x"
exit 1
fi

if [[ "$SHELL" == "bash" ]]; then
if [ "${BASH_VERSINFO:-0}" -lt 4 ]; then
echo -e "\033[31mthe environment needs BASH 4 or above" >&2
exit 1
fi
if [ "${BASH_VERSINFO:-0}" -lt 4 ]; then
echo -e "\033[31mthe environment needs BASH 4 or above" >&2
exit 1
fi
fi

AP_ROOT=$(pwd)
Expand All @@ -21,40 +21,48 @@ dotenv_if_exists dev.env

path="$AP_DEVCACHE_NODE_BIN:$AP_DEVCACHE_BIN"

if ! has make ; then
echo -e "\033[31mmake is not installed"; exit 1
if ! has make; then
echo -e "\033[31mmake is not installed"
exit 1
fi

if ! has go ; then
echo -e "\033[31mgo is not installed"; exit 1
if ! has go; then
echo -e "\033[31mgo is not installed"
exit 1
fi

if ! has kind ; then
if ! has kind; then
echo "kind is not installed. dev environment will try to install it"
fi

if ! has unzip ; then
echo -e "\033[31munzip is not installed"; exit 1
if ! has unzip; then
echo -e "\033[31munzip is not installed"
exit 1
fi

if ! has wget ; then
echo -e "\033[31mwget is not installed"; exit 1
if ! has wget; then
echo -e "\033[31mwget is not installed"
exit 1
fi

if ! has curl ; then
echo -e "\033[31mcurl is not installed"; exit 1
if ! has curl; then
echo -e "\033[31mcurl is not installed"
exit 1
fi

if ! has npm ; then
echo -e "\033[31mnpm is not installed"; exit 1
if ! has npm; then
echo -e "\033[31mnpm is not installed"
exit 1
fi

if ! has jq ; then
echo -e "\033[31mjq is not installed"; exit 1
if ! has jq; then
echo -e "\033[31mjq is not installed"
exit 1
fi

if ! has readlink ; then
echo -e "\033[31mreadlink is not installed"; exit 1
if ! has readlink; then
echo -e "\033[31mreadlink is not installed"
exit 1
fi

TOOLS=${AP_ROOT}/script/tools.sh
Expand All @@ -63,37 +71,40 @@ SEMVER=${AP_ROOT}/script/semver.sh
GOTOOLCHAIN=$(${TOOLS} gotoolchain)
GOTOOLCHAIN_SEMVER=$(echo "${GOTOOLCHAIN}" | sed 's/go*/v/' | tr -d '\n')

GOVERSION=$(${TOOLS} goversion)
GOVERSION_SEMVER=$(echo "${GOVERSION}" | sed 's/go*/v/' | tr -d '\n')

AKASH_DIRENV_SET=1

if [[ "$OSTYPE" == "darwin"* ]]; then
# on MacOS disable deprecation warnings security framework
CGO_CFLAGS=-Wno-deprecated-declarations
# on MacOS disable deprecation warnings security framework
CGO_CFLAGS=-Wno-deprecated-declarations

export CGO_CFLAGS
export CGO_CFLAGS

if ! has brew; then
echo -e "\033[31mhomebrew is not installed. visit https://brew.sh"
exit 1
fi
if ! has brew; then
echo -e "\033[31mhomebrew is not installed. visit https://brew.sh"
exit 1
fi

if [[ -z $HOMEBREW_PREFIX ]]; then
HOMEBREW_PREFIX=$(brew --prefix)
fi
if [[ -z $HOMEBREW_PREFIX ]]; then
HOMEBREW_PREFIX=$(brew --prefix)
fi

# don't use brew list, as it is utterly slow
getopt_bin=${HOMEBREW_PREFIX}/opt/gnu-getopt/bin
# don't use brew list, as it is utterly slow
getopt_bin=${HOMEBREW_PREFIX}/opt/gnu-getopt/bin

if [ ! -d "$getopt_bin" ]; then
echo -e "\033[31mgnu-getopt is not installed. to install \"brew install gnu-getopt\""
exit 1
else
path=$path:"$getopt_bin"
fi
if [ ! -d "$getopt_bin" ]; then
echo -e "\033[31mgnu-getopt is not installed. to install \"brew install gnu-getopt\""
exit 1
else
path=$path:"$getopt_bin"
fi
fi

if [[ -z "$GOPATH" ]]; then
GOPATH=$(go env GOPATH)
export GOPATH
GOPATH=$(go env GOPATH)
export GOPATH
fi

PATH_add "$path"
Expand All @@ -104,6 +115,8 @@ AKASH=$AP_DEVCACHE_BIN/akash
export SEMVER
export GOTOOLCHAIN
export GOTOOLCHAIN_SEMVER
export GOVERSION
export GOVERSION_SEMVER

PATH_add "$path"

Expand Down
2 changes: 1 addition & 1 deletion make/releasing.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GORELEASER_RELEASE ?= false
GORELEASER_DEBUG ?= false
GORELEASER_IMAGE := ghcr.io/goreleaser/goreleaser-cross:$(GOTOOLCHAIN_SEMVER)
GORELEASER_IMAGE := ghcr.io/goreleaser/goreleaser-cross:$(GOVERSION_SEMVER)
GORELEASER_MOUNT_CONFIG ?= false

GORELEASER_SKIP_FLAGS := $(GORELEASER_SKIP)
Expand Down
11 changes: 11 additions & 0 deletions script/tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ function get_gotoolchain() {
echo -n "$gotoolchain"
}

function get_goversion() {
local goversion

goversion=$(go list -mod=readonly -f '{{ .Module.GoVersion }}')

echo -n "go$goversion"
}

function build_akash() {
dev_cache=${AP_DEVCACHE_BIN}
cd "$1" || exit 1
Expand Down Expand Up @@ -80,6 +88,9 @@ case "$1" in
gotoolchain)
get_gotoolchain
;;
goversion)
get_goversion
;;
build-akash)
shift
build_akash "$@"
Expand Down
Loading