Skip to content
Snippets Groups Projects
build.sh 1.34 KiB
Newer Older
Max Adamo's avatar
Max Adamo committed
#!/bin/bash
#
# for windows and Mac check the README
#
Max Adamo's avatar
Max Adamo committed
BIN_NAME=acme-downloader
PATH=$PATH:$(go env GOPATH)/bin
GOPATH=$(go env GOPATH)
export BIN_NAME PATH GOPATH

#LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
#PROG_VERSION=$(echo $LATEST_TAG | sed -e 's/^v//')
PROG_VERSION="1.0"
BUILDTIME=$(date -u '+%Y-%m-%d_%H:%M:%S')

Max Adamo's avatar
Max Adamo committed
run_upx() {
    if ! which upx &>/dev/null; then
        echo "please download upx here https://github.com/upx/upx/releases"
        echo "and store the executable within your \$PATH"
        exit
    fi
    upx --brute ${GOPATH}/bin/${BIN_NAME}
}

Max Adamo's avatar
Max Adamo committed
rm -rf ${GOPATH}/src/github.com/maxadamo/${BIN_NAME} ${GOPATH}/src/gitlab.geant.net/devops/${BIN_NAME}
Max Adamo's avatar
Max Adamo committed
#go get -ldflags "-s -w -X main.appVersion=${PROG_VERSION} -X main.buildTime=${BUILDTIME}" gitlab.geant.net/devops/${BIN_NAME}
go get -ldflags "-s -w -X main.appVersion=${PROG_VERSION} -X main.buildTime=${BUILDTIME}" .
Max Adamo's avatar
Max Adamo committed
if [ $? -gt 0 ]; then
    echo -e "\nthere was an error while compiling the code\n"
    exit
fi
echo ""
#while true; do
#    read -p "Do you wish to run upx against ${BIN_NAME}? (y/n) " yn
#    case $yn in
#    [Yy]*)
#        echo ""
#        run_upx
#        break
#        ;;
#    [Nn]*) break ;;
#    *) echo "Please answer yes or no." ;;
#    esac
#done
Max Adamo's avatar
Max Adamo committed

echo -e "\nthe binary was compiled and it is avilable as:\n - ${GOPATH}/bin/${BIN_NAME}\n"