chore: add checks for RELEASE and VERSION variables

This commit is contained in:
John Paul E. Balandan, CPA 2024-06-17 00:14:08 +08:00
parent 6c7144b47c
commit bab239106a
No known key found for this signature in database
GPG Key ID: 697D84680E3738DA

View File

@ -6,7 +6,26 @@
SOURCE=$1
TARGET=$2
RELEASE=$3
VERSION=`echo "$RELEASE" | cut -c 2-`
# Check if RELEASE is empty
if [ -z "$RELEASE" ]; then
echo "Error: \$RELEASE parameter is empty."
exit 1
fi
VERSION=$(echo "$RELEASE" | cut -c 2-)
# Check if VERSION is empty
if [ -z "$VERSION" ]; then
echo "Error: Failed to extract \$VERSION from \$RELEASE parameter '$RELEASE'."
exit 1
fi
# Check if VERSION matches the format X.Y.Z
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: VERSION '$VERSION' does not match the expected format X.Y.Z."
exit 1
fi
echo "Preparing for version $3"
echo "Merging files from $1 to $2"