From 93e6672b0cb134d4ce6acacedb8990fc898e9fcb Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 10 Oct 2022 16:55:35 +0200 Subject: [PATCH] Update pack script --- pack | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/pack b/pack index 3c94947..d72b168 100755 --- a/pack +++ b/pack @@ -8,14 +8,15 @@ COL_BOLD="\033[01;01m" COL_RED="\033[31m" destDirPart1="dist" +destDirPart2="jess" -function check { +function prep { # output - output="cmd" + output="cmd/jess" # get version version=$(grep "info.Set" cmd/main.go | cut -d'"' -f4) - # build versioned file name with platform - filename="jess_${GOOS}_${GOARCH}_v${version//./-}" + # build versioned file name + filename="jess_v${version//./-}" # platform platform="${GOOS}_${GOARCH}" if [[ $GOOS == "windows" ]]; then @@ -23,47 +24,38 @@ function check { output="${output}.exe" fi # build destination path - destPath=${destDirPart1}/$filename + destPath=${destDirPart1}/${platform}/${destDirPart2}/$filename +} + +function check { + prep # check if file exists if [[ -f $destPath ]]; then - echo "$platform $version already built" + echo "[jess] $platform $version already built" else - echo -e "${COL_BOLD}$platform $version${COL_OFF}" + echo -e "[jess] ${COL_BOLD}$platform $version${COL_OFF}" fi } function build { - # output - output="cmd/cmd" - # get version - version=$(grep "info.Set" cmd/main.go | cut -d'"' -f4) - # build versioned file name with platform - filename="jess_${GOOS}_${GOARCH}_v${version//./-}" - # platform - platform="${GOOS}_${GOARCH}" - if [[ $GOOS == "windows" ]]; then - filename="${filename}.exe" - output="${output}.exe" - fi - # build destination path - destPath=${destDirPart1}/$filename + prep # check if file exists if [[ -f $destPath ]]; then - echo "$platform already built in version $version, skipping..." + echo "[jess] $platform already built in version $version, skipping..." return fi # build ./cmd/build if [[ $? -ne 0 ]]; then - echo -e "\n${COL_BOLD}$platform: ${COL_RED}BUILD FAILED.${COL_OFF}" + echo -e "\n${COL_BOLD}[jess] $platform: ${COL_RED}BUILD FAILED.${COL_OFF}" exit 1 fi mkdir -p $(dirname $destPath) cp $output $destPath - echo -e "\n${COL_BOLD}$platform: successfully built.${COL_OFF}" + echo -e "\n${COL_BOLD}[jess] $platform: successfully built.${COL_OFF}" } function check_all {