mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-30 23:25:36 +03:00
CI: tag docker images properly
Signed-off-by: Yan Minari <yangm97@gmail.com>
This commit is contained in:
parent
ed569e4578
commit
fc615767a0
2 changed files with 74 additions and 7 deletions
61
contrib/semver/docker.sh
Executable file
61
contrib/semver/docker.sh
Executable file
|
@ -0,0 +1,61 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Get the last tag
|
||||
TAG=$(git describe --abbrev=0 --tags --match="v[0-9]*\.[0-9]*\.[0-9]*" 2>/dev/null)
|
||||
|
||||
# Did getting the tag succeed?
|
||||
if [ $? != 0 ] || [ -z "$TAG" ]; then
|
||||
printf -- "unknown"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get the current branch
|
||||
BRANCH=$(git symbolic-ref -q HEAD --short 2>/dev/null)
|
||||
|
||||
# Did getting the branch succeed?
|
||||
if [ $? != 0 ] || [ -z "$BRANCH" ]; then
|
||||
BRANCH="master"
|
||||
fi
|
||||
|
||||
# Split out into major, minor and patch numbers
|
||||
MAJOR=$(echo $TAG | cut -c 2- | cut -d "." -f 1)
|
||||
MINOR=$(echo $TAG | cut -c 2- | cut -d "." -f 2)
|
||||
PATCH=$(echo $TAG | cut -c 2- | cut -d "." -f 3)
|
||||
|
||||
main () {
|
||||
# Check if the branch name is master
|
||||
if [ "$BRANCH" = "master" ]; then
|
||||
printf "latest"
|
||||
exit 0
|
||||
fi
|
||||
# If it is something other than master, just use it
|
||||
printf "$BRANCH"
|
||||
}
|
||||
|
||||
full () {
|
||||
if [ "$BRANCH" = "master" ]; then
|
||||
printf '%d.%d.%d' "$((MAJOR))" "$((MINOR))" "$((PATCH))"
|
||||
exit 0
|
||||
fi
|
||||
printf '%d.%d.%d-%s' "$((MAJOR))" "$((MINOR))" "$((PATCH))" "$BRANCH"
|
||||
}
|
||||
|
||||
majorminor () {
|
||||
if [ "$BRANCH" = "master" ]; then
|
||||
printf '%d.%d' "$((MAJOR))" "$((MINOR))"
|
||||
exit 0
|
||||
fi
|
||||
printf '%d.%d-%s' "$((MAJOR))" "$((MINOR))" "$BRANCH"
|
||||
}
|
||||
|
||||
major () {
|
||||
if [ "$BRANCH" = "master" ]; then
|
||||
printf "$((MAJOR))"
|
||||
exit 0
|
||||
fi
|
||||
printf '%d-%s' "$((MAJOR))" "$BRANCH"
|
||||
}
|
||||
|
||||
for arg in "$@"; do
|
||||
$arg
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue