I use the following bash/shell script to semi-automate the git add/commit/push routine on my project:
git_push.sh
#!/bin/bash
# Mini Config
RColor='\e[0m'
Red='\e[0;31m';
Green='\e[0;32m';
Yellow='\e[0;33m'
# Change To Working Directory
clear;
cd $HOME/public_html/iwms_reboot;
# Get Git Commit Notes
echo -en "\r\n${Green}Enter commit notes: ${Yellow}";
read notes;
if [[ -z "$notes" ]]
then
echo -e "\r\n${Red}ERROR: You have not entered any git commit notes.${RColor}\r\n";
exit 0;
fi
echo -e "${RColor}";
# Git Add, Commit & Push
git add .;
git commit -m "${notes}";
echo -e "\r\n";
git push;
echo -e "\r\n";
This works perfectly fine.
I want to take this one step further. On my prject, there is a single file called version.php with the following lines of code:
<?php
// Script Version
$script_version = 'v1.0.5';
?>
My question is, is it possible to use bash/shell scripting to load this file's content and find the number after the 2nd
period (.
) and increment it by one?
i.e. v1.0.5
will become v1.0.6
This way, I can run this version number updating function before my (git add/commit/push) routine to implement an automatic minor version
number update functionality on my project. I.e. script version number goes up automatically every time I commit.