github.com/NpoolPlatform/chain-middleware@v0.0.0-20240228100535-eb1bcf896eb9/hack/release-docker-image.sh (about) 1 #!/usr/bin/env bash 2 3 set -o errexit 4 set -o nounset 5 set -o pipefail 6 7 PLATFORM=linux/amd64 8 OUTPUT=./output 9 10 pkg=github.com/NpoolPlatform/go-service-framework/pkg/version 11 12 OS="${PLATFORM%/*}" 13 ARCH=$(basename "$PLATFORM") 14 15 if git_status=$(git status --porcelain --untracked=no 2>/dev/null) && [[ -z "${git_status}" ]]; then 16 git_tree_state=clean 17 fi 18 19 set +e 20 ## For testing or production environment, pass the second variable 21 version=`git describe --exact-match --tags $(git log -n1 --pretty='%h')` 22 if [ ! $? -eq 0 ]; then 23 branch=`git rev-parse --abbrev-ref HEAD | grep -v ^HEAD$ || git rev-parse HEAD` 24 if [ "x$branch" == "xmaster" ]; then 25 version=latest 26 else 27 version=`echo $branch | awk -F '/' '{print $2}'` 28 fi 29 ## Do we need commit ? 30 # commit=`git rev-parse HEAD` 31 # version=$version-$commit 32 fi 33 set -e 34 35 registry=uhub.service.ucloud.cn 36 if [ "x" != $2 ]; then 37 registry=$2 38 fi 39 40 service_name=$1 41 42 echo "Release docker image for $PLATFORM -- $version" 43 44 user=`whoami` 45 if [ "$user" == "root" ]; then 46 docker push $registry/entropypool/$service_name:$version 47 else 48 sudo docker push $registry/entropypool/$service_name:$version 49 fi