mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 09:22:43 +03:00
45bcb6b536
Co-authored-by: Shahidh K Muhammed <muhammedshahid.k@gmail.com>
28 lines
672 B
Bash
Executable File
28 lines
672 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -eo pipefail
|
|
IFS=$'\n\t'
|
|
|
|
ROOT="${BASH_SOURCE[0]%/*}"
|
|
|
|
SEMVER_REGEX="v?([0-9]+)(\.[0-9]+)?(\.[0-9]+)?(-([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?(\+([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?"
|
|
CHANNEL_REGEX="^[a-z]+"
|
|
LATEST_TAG=$(git describe --tags --abbrev=0)
|
|
|
|
VERSION=""
|
|
channel="stable"
|
|
|
|
if [[ "$LATEST_TAG" =~ $SEMVER_REGEX ]]; then
|
|
major=${BASH_REMATCH[1]}
|
|
minor=${BASH_REMATCH[2]}
|
|
release=${BASH_REMATCH[5]}
|
|
if [[ "$release" =~ $CHANNEL_REGEX ]]; then
|
|
channel="${BASH_REMATCH[0]}"
|
|
fi
|
|
VERSION="channel/$channel/v$major$minor"
|
|
fi
|
|
|
|
if [ -z "$VERSION" ]; then VERSION="versioned/$($ROOT/get-version.sh)"; fi
|
|
|
|
echo $VERSION
|