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() {
|
function exprPath() {
|
||||||
local path
|
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}
|
echo ${path}
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function gitTag() {
|
function gitTag() {
|
||||||
local expr_path
|
local expr_path gopath gopkg mod
|
||||||
|
local tag
|
||||||
|
|
||||||
expr_path=$(exprPath)
|
expr_path=$(exprPath)
|
||||||
|
if [[ "${expr_path}" ]]; then
|
||||||
tag=$(git -C "${expr_path}" tag -l --sort=-version:refname "v*"|head -1)
|
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}
|
echo ${tag}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createVersionSource() {
|
function createVersionSource() {
|
||||||
|
set -x
|
||||||
local tag
|
local tag
|
||||||
tag=$(gitTag)
|
tag=$(gitTag)
|
||||||
|
if [ -z "${tag}" ]; then
|
||||||
|
tag="n/a"
|
||||||
|
fi
|
||||||
|
set +x
|
||||||
|
|
||||||
cat >version.go <<eot
|
cat >version.go <<eot
|
||||||
// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com).
|
// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
|
Loading…
Reference in New Issue
Block a user