graphql-engine/scripts/get-console-assets-version.sh
Aravind Shankar 45bcb6b536
cli, server: use prerelease tag as channel for console assets cdn (#3975)
Co-authored-by: Shahidh K Muhammed <muhammedshahid.k@gmail.com>
2020-03-04 20:10:47 +05:30

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