From c386b15fcf6c87c4833a1cfeeaf7c897ff2a5663 Mon Sep 17 00:00:00 2001 From: Massimiliano Adamo <massimiliano.adamo@geant.org> Date: Mon, 31 May 2021 20:46:59 +0200 Subject: [PATCH] testing git tags --- .gitlab-ci-psnc.yml | 2 +- build.sh | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci-psnc.yml b/.gitlab-ci-psnc.yml index 5f6243f..c2e40ad 100644 --- a/.gitlab-ci-psnc.yml +++ b/.gitlab-ci-psnc.yml @@ -20,7 +20,7 @@ upload_linux_binary: only: - tags script: - - ./build.sh --os=linux --arch=amd64 --upx + - ./build.sh --os=linux --arch=amd64 --version=$CI_COMMIT_TAG --upx - 'curl --header "JOB-TOKEN: $PROJECT_ACCESS_TOKEN" --upload-file $CI_PROJECT_NAME "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/${CI_COMMIT_TAG}/${CI_PROJECT_NAME}"' tags: - visnu_shell diff --git a/build.sh b/build.sh index e54381e..f52cf30 100755 --- a/build.sh +++ b/build.sh @@ -11,7 +11,7 @@ unset GOBIN BIN_NAME=acme-downloader PATH=$PATH:$(go env GOPATH)/bin GOPATH=$(go env GOPATH) -PROG_VERSION="1.0" +#PROG_VERSION="1.0" BUILDTIME=$(date -u '+%Y-%m-%d_%H:%M:%S') REPO_DIR=$(dirname $0) if [ "$REPO_DIR" = '.' ]; then @@ -30,6 +30,7 @@ usage() { echo " --arch=ARCH (Compile binary for this Architecture)" echo " --upx (Enable UPX compression)" echo " --no-upx (Disable UPX compression)" + echo " --version (Version number. If not used it will be the latest tag)" echo "" echo " Below is a list of supported OS/Arch combinations:" echo "OS ARCH" @@ -37,7 +38,7 @@ usage() { exit } -OPTS=$(getopt -o "h" --longoptions "help,os:,arch:,upx,no-upx" -- "$@") +OPTS=$(getopt -o "h" --longoptions "help,os:,arch:,upx,no-upx:,version:" -- "$@") eval set -- "$OPTS" while true; do @@ -59,6 +60,10 @@ while true; do --no-upx) NOUPX='NOUPX' ;; + --version) + shift + VERSION="$1" + ;; --) shift break @@ -67,6 +72,12 @@ while true; do shift done +if [ -z $VERSION ]; then + PROG_VERSION=$(git describe --tags $(git rev-list --tags --max-count=1) | tr -d v) +else + PROG_VERSION=$(echo $PROG_VERSION | tr -f v) +fi + if [ -z $OS ] || [ -z $ARCH ]; then echo -e "\nYou need to supply OS and Architecture\n" usage -- GitLab