Skip to content

Commit

Permalink
Fix wrong version in build script
Browse files Browse the repository at this point in the history
  • Loading branch information
STARRY-S committed Oct 5, 2023
1 parent 1b37c9c commit d96ad9a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ if [[ ! -e "config.yaml" ]]; then
cp config.yaml.example config.yaml
fi

GITCOMMIT=$(git rev-parse HEAD || true)
GITCOMMIT=$(git rev-parse HEAD 2> /dev/null || true)
VERSION=$(git describe --tags 2>/dev/null || true)
BUILD_FLAG=""
if [[ "${GITCOMMIT}" != "UNKNOW" ]]; then
if [[ ! -z "${GITCOMMIT}" ]]; then
BUILD_FLAG="${BUILD_FLAG} -X 'github.com/STARRY-S/telebot/pkg/utils.gitCommit=${GITCOMMIT}'"
fi
BUILD_FLAG="${BUILD_FLAG} -X 'github.com/STARRY-S/telebot/pkg/utils.version=${VERSION}'"
if [[ ! -z "${GITCOMMIT}" ]]; then
BUILD_FLAG="${BUILD_FLAG} -X 'github.com/STARRY-S/telebot/pkg/utils.version=${VERSION}'"
fi

CGO_ENABLED=0 go build -ldflags "${BUILD_FLAG}" .
CGO_ENABLED=0 go build -ldflags "${BUILD_FLAG:-}" .

echo "--------------------------"
ls -alh telebot
echo "--------------------------"

TAG=""
if [[ ! -z "$VERSION" ]]; then
TAG=":${VERSION}"
fi
Expand All @@ -35,4 +35,4 @@ docker build \
--build-arg no_proxy=${no_proxy:-} \
--build-arg NO_PROXY=${NO_PROXY:-} \
--network=host \
-t hxstarrys/telebot${TAG} .
-t hxstarrys/telebot${TAG:-} .

0 comments on commit d96ad9a

Please sign in to comment.