From 3005ec74b33fbe44b568240a5b95a7f54e0e3f3b Mon Sep 17 00:00:00 2001 From: Daniel Hiltgen Date: Mon, 22 Jan 2024 17:12:20 -0800 Subject: [PATCH] Set a default version using git describe If a VERSION is not specified, this will generate a version string that represents the state of the repo. For example `0.1.21-12-gffaf52e-dirty` representing 12 commits away from 0.1.21 tag, on commit gffaf52e and the tree is dirty. --- scripts/build_darwin.sh | 2 +- scripts/build_docker.sh | 2 +- scripts/build_linux.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/build_darwin.sh b/scripts/build_darwin.sh index 114240e3..381bcba5 100755 --- a/scripts/build_darwin.sh +++ b/scripts/build_darwin.sh @@ -2,7 +2,7 @@ set -e -export VERSION=${VERSION:-0.0.0} +export VERSION=${VERSION:-$(git describe --tags --first-parent --abbrev=7 --long --dirty --always | sed -e "s/^v//g")} export GOFLAGS="'-ldflags=-w -s \"-X=github.com/jmorganca/ollama/version.Version=$VERSION\" \"-X=github.com/jmorganca/ollama/server.mode=release\"'" mkdir -p dist diff --git a/scripts/build_docker.sh b/scripts/build_docker.sh index 74a9ac84..ef02a144 100755 --- a/scripts/build_docker.sh +++ b/scripts/build_docker.sh @@ -2,7 +2,7 @@ set -eu -export VERSION=${VERSION:-0.0.0} +export VERSION=${VERSION:-$(git describe --tags --first-parent --abbrev=7 --long --dirty --always | sed -e "s/^v//g")} export GOFLAGS="'-ldflags=-w -s \"-X=github.com/jmorganca/ollama/version.Version=$VERSION\" \"-X=github.com/jmorganca/ollama/server.mode=release\"'" docker build \ diff --git a/scripts/build_linux.sh b/scripts/build_linux.sh index 75018837..338dbcd5 100755 --- a/scripts/build_linux.sh +++ b/scripts/build_linux.sh @@ -2,7 +2,7 @@ set -eu -export VERSION=${VERSION:-0.0.0} +export VERSION=${VERSION:-$(git describe --tags --first-parent --abbrev=7 --long --dirty --always | sed -e "s/^v//g")} export GOFLAGS="'-ldflags=-w -s \"-X=github.com/jmorganca/ollama/version.Version=$VERSION\" \"-X=github.com/jmorganca/ollama/server.mode=release\"'" BUILD_ARCH=${BUILD_ARCH:-"amd64 arm64"}