Commit b09bd72b authored by Waqas Riaz's avatar Waqas Riaz

updated increment-version.sh

parent 326b17ae
Pipeline #4042 passed with stages
in 24 seconds
#!/bin/bash #!/bin/bash
# Read the current version number from the version.txt file # Extract the version number from VERSION.txt
VERSION=$(cat version.txt) VERSION=$(cat version.txt)
echo "Current version is ${VERSION}"
# Increment the version number # Use a regular expression to extract the major, minor, and patch numbers
NEW_VERSION=$(echo $VERSION | awk -F. '{$NF = $NF + 1;} 1' OFS=. | sed 's/.$//') if [[ ${VERSION} =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
MAJOR=${BASH_REMATCH[1]}
MINOR=${BASH_REMATCH[2]}
PATCH=${BASH_REMATCH[3]}
else
echo "Could not extract version number from VERSION.txt"
exit 1
fi
# Increment the patch number by 1
PATCH=$((${PATCH}+1))
# Construct the new version string
NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}"
echo "New version is ${NEW_VERSION}"
# Write the new version string back to VERSION.txt
echo "${NEW_VERSION}" > version.txt
# Update the version.txt file with the new version number
echo $NEW_VERSION > version.txt
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment