Skip to content

chore: fix generator script for dev versions #167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions scripts/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,29 @@ done

# jar was downloaded from here https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.34/

if [[ $VERSION == *"develop"* ]]; then
SANITIZED_VERSION=$(sed 's/-develop//g' <<< $VERSION)
SANITIZED_VERSION=$(sed 's/\.[0-9]*$//g' <<< $SANITIZED_VERSION)
BUILD_VERSION=$(grep -o '[0-9]*$' <<< $VERSION)
VERSION="dev-$SANITIZED_VERSION-$BUILD_VERSION"
VERSION=${VERSION//develop/dev}

if [[ $VERSION =~ ^dev[.-]([0-9]+)[.-]([0-9]+)[.-]([0-9]+)[.-]([0-9]+)$ ]]; then
# Example for the regex above:
# dev.1.0.0.0
# dev-1.0.0-0
# dev.1.0.0-0
# dev-1.0.0.0
VERSION="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${BASH_REMATCH[3]}-beta.${BASH_REMATCH[4]}"
elif [[ $VERSION =~ ^([0-9]+)[.-]([0-9]+)[.-]([0-9]+)[.-]dev[.-]([0-9]+)$ ]]; then
# Example for the regex above:
# 1.0.0.dev.0
# 1.0.0.dev-0
# 1.0.0-dev-0
# 1.0.0-dev.0
VERSION="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${BASH_REMATCH[3]}-beta.${BASH_REMATCH[4]}"
elif [[ $VERSION == dev-* ]]; then
_temp_part=${VERSION#dev-}
VERSION="${_temp_part//-/.}-beta"
elif [[ $VERSION == *-dev* ]]; then
_temp_part=${VERSION#*-dev}
_temp_part=${_temp_part//-/.}
VERSION="${VERSION%%-dev*}-beta$_temp_part"
fi

echo "VERSION: $VERSION"
Expand Down
Loading