Update pack script
This commit is contained in:
parent
d209a94a7d
commit
93e6672b0c
1 changed files with 16 additions and 24 deletions
40
pack
40
pack
|
@ -8,14 +8,15 @@ COL_BOLD="\033[01;01m"
|
||||||
COL_RED="\033[31m"
|
COL_RED="\033[31m"
|
||||||
|
|
||||||
destDirPart1="dist"
|
destDirPart1="dist"
|
||||||
|
destDirPart2="jess"
|
||||||
|
|
||||||
function check {
|
function prep {
|
||||||
# output
|
# output
|
||||||
output="cmd"
|
output="cmd/jess"
|
||||||
# get version
|
# get version
|
||||||
version=$(grep "info.Set" cmd/main.go | cut -d'"' -f4)
|
version=$(grep "info.Set" cmd/main.go | cut -d'"' -f4)
|
||||||
# build versioned file name with platform
|
# build versioned file name
|
||||||
filename="jess_${GOOS}_${GOARCH}_v${version//./-}"
|
filename="jess_v${version//./-}"
|
||||||
# platform
|
# platform
|
||||||
platform="${GOOS}_${GOARCH}"
|
platform="${GOOS}_${GOARCH}"
|
||||||
if [[ $GOOS == "windows" ]]; then
|
if [[ $GOOS == "windows" ]]; then
|
||||||
|
@ -23,47 +24,38 @@ function check {
|
||||||
output="${output}.exe"
|
output="${output}.exe"
|
||||||
fi
|
fi
|
||||||
# build destination path
|
# build destination path
|
||||||
destPath=${destDirPart1}/$filename
|
destPath=${destDirPart1}/${platform}/${destDirPart2}/$filename
|
||||||
|
}
|
||||||
|
|
||||||
|
function check {
|
||||||
|
prep
|
||||||
|
|
||||||
# check if file exists
|
# check if file exists
|
||||||
if [[ -f $destPath ]]; then
|
if [[ -f $destPath ]]; then
|
||||||
echo "$platform $version already built"
|
echo "[jess] $platform $version already built"
|
||||||
else
|
else
|
||||||
echo -e "${COL_BOLD}$platform $version${COL_OFF}"
|
echo -e "[jess] ${COL_BOLD}$platform $version${COL_OFF}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function build {
|
function build {
|
||||||
# output
|
prep
|
||||||
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
|
|
||||||
|
|
||||||
# check if file exists
|
# check if file exists
|
||||||
if [[ -f $destPath ]]; then
|
if [[ -f $destPath ]]; then
|
||||||
echo "$platform already built in version $version, skipping..."
|
echo "[jess] $platform already built in version $version, skipping..."
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# build
|
# build
|
||||||
./cmd/build
|
./cmd/build
|
||||||
if [[ $? -ne 0 ]]; then
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
mkdir -p $(dirname $destPath)
|
mkdir -p $(dirname $destPath)
|
||||||
cp $output $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 {
|
function check_all {
|
||||||
|
|
Loading…
Add table
Reference in a new issue