build.bash: tag-date added to the version.go file

This commit is contained in:
Celestino Amoroso 2025-03-08 11:35:01 +01:00
parent f30a38c099
commit 9ca9d23315

View File

@ -148,11 +148,34 @@ function gitTag() {
echo ${tag}
}
function gitTagDate() {
local tag_name=${1}
local expr_path gopath gopkg mod
local tag_date
expr_path=$(exprPath)
if [[ "${expr_path}" ]]; then
tag_date=$(git -C "${expr_path}" show --no-patch --format=%ci "${tag_name}")
else
tag_date="n/a"
# gopath=$(go env GOPATH)
# gopkg="${gopath}/pkg/mod/git.portale-stac.it/go-pkg"
# if cd "${gopkg}" 2>/dev/null; then
# mod=$(ls -1v |grep expr@|tail -1)
# tag=${mod##*@}
# cd - >/dev/null
# fi
fi
echo ${tag_date}
}
function createVersionSource() {
local tag
local tag tag_date
tag=$(gitTag)
if [ -z "${tag}" ]; then
tag="n/a"
else
tag_date=$(gitTagDate "${tag}")
fi
cat >version.go <<eot
@ -166,6 +189,7 @@ const (
PROGNAME = "${PROGRAM_NAME}"
VERSION = "v${PROGRAM_VERSION}(build $(getBuildCount)),$(date +"%Y/%m/%d") (celestino.amoroso@portale-stac.it)"
EXPR_VERSION = "${tag}"
EXPR_DATE = "${tag_date}"
)
eot
}