From 4d73928bd07599905192d58b2aaebe86a6a01729 Mon Sep 17 00:00:00 2001 From: Ole Martin Handeland Date: Tue, 22 Nov 2022 13:02:05 +0100 Subject: [PATCH] Release script: version number sanity check (#684) Co-authored-by: Ole Martin Handeland --- .github/scripts/release.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/scripts/release.sh b/.github/scripts/release.sh index 50e008977c..22eed55e09 100755 --- a/.github/scripts/release.sh +++ b/.github/scripts/release.sh @@ -74,6 +74,7 @@ AUTHOR_NAME="$(echo "$AUTHOR_FULL" | sed -r 's/<.*//')" AUTHOR_EMAIL="$(echo "$AUTHOR_FULL" | sed -r 's/^.*?//')" COMMIT_ID=$(git rev-parse HEAD~0) +echo "Git tag: $CURRENT_VERSION" echo "Full version: $APP_FULL" echo "Major version: $APP_MAJOR" echo "Major + minor: $APP_MAJOR_MINOR" @@ -83,6 +84,17 @@ echo "Author email: $AUTHOR_EMAIL" echo "Commit ID: $COMMIT_ID" echo "-------------------------------------" +if ! [[ "$CURRENT_VERSION" =~ ^v ]]; then + echo "Error: Expected git tag to start with v" + exit 1 +fi + +VERSION_REGEX="^[\d\.]+(-[a-z0-9.]+)?$" +if ! echo "$APP_FULL" | grep --quiet --perl-regexp "$VERSION_REGEX"; then + echo "Error: Broken/unexpected version number: $APP_FULL" + exit 1 +fi + COMMIT_FILE=$(mktemp --suffix=-cdn-commit) { echo "$AUTHOR_FULL updated altinn-app-frontend to $APP_FULL" @@ -129,7 +141,7 @@ cp -fr $SOURCE/* "$TARGET/$APP_FULL/" echo " * Updating index.json" ls -1 | \ - grep --perl-regexp '^[\d\.]+(-[a-z0-9.]+)?$' | \ + grep --perl-regexp "$VERSION_REGEX" | \ sort --version-sort | \ jq --raw-input --slurp 'split("\n") | map(select(. != ""))' > index.json