Skip to content

Commit

Permalink
Update pack script
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaavi committed Oct 10, 2022
1 parent d209a94 commit 93e6672
Showing 1 changed file with 16 additions and 24 deletions.
40 changes: 16 additions & 24 deletions pack
Original file line number Diff line number Diff line change
Expand Up @@ -8,62 +8,54 @@ 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
filename="${filename}.exe"
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 {
Expand Down

0 comments on commit 93e6672

Please sign in to comment.