Skip to content

Commit

Permalink
fix: issue/1 entrypoint.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
jpradoar authored Nov 16, 2024
1 parent 76cd3b0 commit 54ecf99
Showing 1 changed file with 9 additions and 22 deletions.
31 changes: 9 additions & 22 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,19 @@
COMMIT_MSG=$1
VERSION=$2

# Validate inputs
if [[ -z "$COMMIT_MSG" || -z "$VERSION" ]]; then
echo "Error: COMMIT_MSG or VERSION is not provided."
exit 1
fi

# Validate version format
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: VERSION must follow X.Y.Z format"
exit 1
fi

# Split version into X, Y, Z
IFS='.' read -r X Y Z <<< "$VERSION"
base_version="$X.$Y.$Z"
# Make some vars to manipulate each part of a full version (X.Y.Z)
X=$(echo $VERSION|cut -d. -f1)
Y=$(echo $VERSION|cut -d. -f2)
Z=$(echo $VERSION|cut -d. -f3)
base_version=$(echo $X.$Y.$Z)
cusotm_version=$(echo $COMMIT_MSG|cut -d':' -f1)

# Determine new version based on commit message
if [[ "$COMMIT_MSG" =~ ^(major:|breaking:|release:|big-feature:) ]]; then
# Increment major version
# Create new version using type (major,minor,patch,beta,none)
if [[ "$COMMIT_MSG" =~ ^(major:|breaking:|release:|big-feature:) ]]; then
NewVersion=$(($X+1)).0.0
elif [[ "$COMMIT_MSG" =~ ^(minor:|enhancement:|update:|feature:) ]]; then
# Increment minor version
NewVersion=$X.$(($Y+1)).0
elif [[ "$COMMIT_MSG" =~ ^(patch:|fix:) ]]; then
# Increment patch version
elif [[ "$COMMIT_MSG" =~ (fix:|patch:) ]]; then
NewVersion=$X.$Y.$(($Z+1))
elif [[ "$COMMIT_MSG" =~ ^test: ]]; then
# Generate test version string
Expand All @@ -43,7 +31,6 @@ else
NewVersion="$base_version-$custom_version"
fi

# Output results
echo "COMMIT MSG: $COMMIT_MSG"
echo "OLD VERSION: $VERSION"
echo "NEW_VERSION: $NewVersion"
Expand Down

0 comments on commit 54ecf99

Please sign in to comment.