2011-11-28 16:18:23 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2015-02-08 22:36:57 +00:00
|
|
|
# Bumps the micro version according to the number of commits on this branch
|
2011-11-28 16:18:23 +00:00
|
|
|
#
|
|
|
|
# To have git run this script on commit, create a "pre-commit" text file in
|
|
|
|
# .git/hooks/ with the following content:
|
|
|
|
# #!/bin/sh
|
2011-12-09 22:47:44 +00:00
|
|
|
# if [ -x ./_pre-commit.sh ]; then
|
2018-05-12 10:37:07 +00:00
|
|
|
# . ./_pre-commit.sh
|
2011-12-09 22:47:44 +00:00
|
|
|
# fi
|
2011-11-28 16:18:23 +00:00
|
|
|
|
|
|
|
type -P sed &>/dev/null || { echo "sed command not found. Aborting." >&2; exit 1; }
|
|
|
|
type -P git &>/dev/null || { echo "git command not found. Aborting." >&2; exit 1; }
|
|
|
|
|
2018-05-12 10:37:07 +00:00
|
|
|
if [ -x ./_detect-amend.sh ]; then
|
|
|
|
. ./_detect-amend.sh
|
|
|
|
fi
|
|
|
|
|
2018-10-19 13:34:34 +00:00
|
|
|
BUILD=`git rev-list HEAD --count`
|
2014-02-01 00:03:57 +00:00
|
|
|
# adjust so that we match the github commit count
|
2018-10-19 13:34:34 +00:00
|
|
|
((BUILD++))
|
2015-02-08 22:36:57 +00:00
|
|
|
# there may be a better way to prevent improper micro on amend. For now the detection
|
2011-11-28 16:18:23 +00:00
|
|
|
# of a .amend file in the current directory will do
|
|
|
|
if [ -f ./.amend ]; then
|
2018-10-19 13:34:34 +00:00
|
|
|
((BUILD--))
|
2011-11-28 16:18:23 +00:00
|
|
|
rm ./.amend;
|
|
|
|
fi
|
2018-10-19 13:34:34 +00:00
|
|
|
echo "setting micro to $BUILD"
|
2011-11-28 16:18:23 +00:00
|
|
|
|
|
|
|
cat > cmd.sed <<\_EOF
|
2018-10-19 13:34:34 +00:00
|
|
|
s/^\([ \t]*\)*\(FILE\|PRODUCT\)VERSION\([ \t]*\)\([0-9]*\),\([0-9]*\),[0-9]*,\(.*\)/\1\2VERSION\3\4,\5,@@BUILD@@,\6/
|
|
|
|
s/^\([ \t]*\)VALUE\([ \t]*\)"\(File\|Product\)Version",\([ \t]*\)"\(.*\)\..*"[ \t]*/\1VALUE\2"\3Version",\4"\5.@@BUILD@@"/
|
|
|
|
s/^\(.*\)"Rufus \(.*\)\..*"\(.*\)/\1"Rufus \2.@@BUILD@@"\3/
|
|
|
|
s/^\([ \t]*\)Version="\([0-9]*\)\.\([0-9]*\)\.[0-9]*\.\([0-9]*\)"\(.*\)/\1Version="\2.\3.@@BUILD@@.\4"\5/
|
2011-11-28 16:18:23 +00:00
|
|
|
_EOF
|
|
|
|
|
|
|
|
# First run sed to substitute our variable in the sed command file
|
2018-10-19 13:34:34 +00:00
|
|
|
sed -i -e "s/@@BUILD@@/$BUILD/g" cmd.sed
|
2011-11-28 16:18:23 +00:00
|
|
|
# Run sed to update the nano version
|
2017-04-20 11:58:04 +00:00
|
|
|
sed -b -i -f cmd.sed src/rufus.rc
|
2021-02-05 17:20:54 +00:00
|
|
|
sed -b -i -f cmd.sed res/appstore/Package.appxmanifest
|
2014-02-03 19:22:32 +00:00
|
|
|
# NB: we need to run git add else the modified files may be ignored
|
2011-12-05 11:19:05 +00:00
|
|
|
git add src/rufus.rc
|
2021-02-05 17:20:54 +00:00
|
|
|
git add res/appstore/Package.appxmanifest
|
2011-11-28 16:18:23 +00:00
|
|
|
|
2011-11-28 20:06:47 +00:00
|
|
|
rm cmd.sed
|