Skip to content

Commit

Permalink
Fixed bug with production tags
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot[bot] authored and KostLinux committed Jun 2, 2024
1 parent 361cb4d commit 88951ac
Showing 1 changed file with 37 additions and 10 deletions.
47 changes: 37 additions & 10 deletions bin/create_release_tag.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
#!/bin/sh

ENVIRONMENT=$1
INCREMENT=$2

if [[ -z $ENVIRONMENT || ($ENVIRONMENT != "test" && $ENVIRONMENT != "prod") ]]; then
echo "Please specify the environment as either 'prod' or 'test'."
echo "Example: ./bin/create_release_tag.sh test"
echo "Example: ./bin/create_release_tag.sh test patch"
exit 1
fi

if [[ -z $INCREMENT || ($INCREMENT != "major" && $INCREMENT != "minor" && $INCREMENT != "patch") ]]; then
echo "Please specify what to increment as either 'major', 'minor', or 'patch'."
echo "Example: ./bin/create_release_tag.sh test patch"
exit 1
fi

Expand All @@ -17,19 +24,39 @@ if [[ $? -ne 0 ]]; then
fi

# Get the latest tag
latest_tag=$(git describe --tags --abbrev=0)
if [[ $ENVIRONMENT == "prod" ]]; then
latest_tag=$(git tag -l 'v[0-9]*.[0-9]*.[0-9]*' | grep -v -- '-alpha' | sort -V | tail -n 1)
else
latest_tag=$(git tag -l 'v[0-9]*.[0-9]*.[0-9]*-alpha' | sort -V | tail -n 1)
fi
echo "Latest tag: $latest_tag"

# Extract the version number from the latest tag
version=$(echo "$latest_tag" | sed -E 's/v([0-9]+\.[0-9]+\.[0-9]+).*/\1/')
# Check if latest_tag is empty
if [[ -z $latest_tag ]]; then
major=0
minor=0
patch=0
else
# Extract the version number from the latest tag
version=$(echo "$latest_tag" | sed -E 's/v([0-9]+\.[0-9]+\.[0-9]+).*/\1/')

# Split the version into major, minor, and patch
major=$(echo $version | cut -d. -f1)
minor=$(echo $version | cut -d. -f2)
patch=$(echo $version | cut -d. -f3)
# Split the version into major, minor, and patch
major=$(echo $version | cut -d. -f1)
minor=$(echo $version | cut -d. -f2)
patch=$(echo $version | cut -d. -f3)
fi

# Increment the patch number
patch=$((patch + 1))
# Increment the specified version part
if [[ $INCREMENT == "major" ]]; then
major=$((major + 1))
minor=0
patch=0
elif [[ $INCREMENT == "minor" ]]; then
minor=$((minor + 1))
patch=0
elif [[ $INCREMENT == "patch" ]]; then
patch=$((patch + 1))
fi

# Join the major, minor, and patch into the new version
new_version="$major.$minor.$patch"
Expand Down

0 comments on commit 88951ac

Please sign in to comment.