Skip to content

Commit

Permalink
Release script: version number sanity check (#684)
Browse files Browse the repository at this point in the history
Co-authored-by: Ole Martin Handeland <git@olemartin.org>
  • Loading branch information
olemartinorg and Ole Martin Handeland authored Nov 22, 2022
1 parent 63c6526 commit 4d73928
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion .github/scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ AUTHOR_NAME="$(echo "$AUTHOR_FULL" | sed -r 's/<.*//')"
AUTHOR_EMAIL="$(echo "$AUTHOR_FULL" | sed -r 's/^.*?<//' | sed '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"
Expand All @@ -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"
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 4d73928

Please sign in to comment.