build.bash: added support to env that has no go.work file
This commit is contained in:
parent
913ff916e1
commit
05d8d2d298
23
build.bash
23
build.bash
@ -124,20 +124,39 @@ function buildLocal() {
|
||||
|
||||
function exprPath() {
|
||||
local path
|
||||
path=$(grep -m1 -F "go-pkg/expr" go.work)
|
||||
if path=$(grep 2>/dev/null -m1 -F "go-pkg/expr" go.work); then
|
||||
echo ${path}
|
||||
fi
|
||||
}
|
||||
|
||||
function gitTag() {
|
||||
local expr_path
|
||||
local expr_path gopath gopkg mod
|
||||
local tag
|
||||
|
||||
expr_path=$(exprPath)
|
||||
if [[ "${expr_path}" ]]; then
|
||||
tag=$(git -C "${expr_path}" tag -l --sort=-version:refname "v*"|head -1)
|
||||
else
|
||||
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}
|
||||
}
|
||||
|
||||
function createVersionSource() {
|
||||
set -x
|
||||
local tag
|
||||
tag=$(gitTag)
|
||||
if [ -z "${tag}" ]; then
|
||||
tag="n/a"
|
||||
fi
|
||||
set +x
|
||||
|
||||
cat >version.go <<eot
|
||||
// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com).
|
||||
// All rights reserved.
|
||||
|
Loading…
Reference in New Issue
Block a user