This commit is contained in:
Mike Schwörer 2022-11-19 13:34:21 +01:00
parent b643bded8a
commit b35d6ca0b0
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
3 changed files with 48 additions and 0 deletions

View File

@ -4,3 +4,6 @@ run:
test: test:
go test ./... go test ./...
version:
_data/version.sh

27
_data/version.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/bash
set -o nounset # disallow usage of unset vars ( set -u )
set -o errexit # Exit immediately if a pipeline returns non-zero. ( set -e )
set -o errtrace # Allow the above trap be inherited by all functions in the script. ( set -E )
set -o pipefail # Return value of a pipeline is the value of the last (rightmost) command to exit with a non-zero status
IFS=$'\n\t' # Set $IFS to only newline and tab.
curr_vers=$(git describe --tags --abbrev=0 | sed 's/v//g')
next_ver=$(echo "$curr_vers" | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{if(length($NF+1)>length($NF))$(NF-1)++; $NF=sprintf("%0*d", length($NF), ($NF+1)%(10^length($NF))); print}')
echo ""
echo "> Current Version: ${curr_vers}"
echo "> Next Version: ${next_ver}"
echo ""
git add --verbose .
git commit -a -m "v${next_ver}"
git tag "v${next_ver}"
git push
git push --tags

View File

@ -29,3 +29,21 @@ func Min[T langext.OrderedConstraint](v1 T, v2 T) T {
return v2 return v2
} }
} }
func Abs[T langext.NumberConstraint](v T) T {
if v < 0 {
return -v
} else {
return v
}
}
func Clamp[T langext.NumberConstraint](v T, min T, max T) T {
if v < min {
return min
} else if v > max {
return max
} else {
return v
}
}