forked from disorderedmaterials/dissolve
-
Notifications
You must be signed in to change notification settings - Fork 0
/
changeversion
executable file
·114 lines (101 loc) · 4.77 KB
/
changeversion
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
# Change the version of the source code to the supplied value
# Day Suffix Function
DaySuffix() {
case `date +%d` in
1|21|31) echo "st";;
2|22) echo "nd";;
3|23) echo "rd";;
*) echo "th";;
esac
}
# Check that a version information was correctly supplied
if [ "$#" -eq "0" ]
then
echo "Checking current version numbers only..."
TEST="true"
elif [ "$1" = "bump" ]
then
echo "Bumping version number..."
MAJOR=`grep 'set(VERSION_MAJOR' ./CMakeLists.txt | sed -e 's/set(VERSION_MAJOR \"\([0-9a-z\.]\+\)\")/\1/g'`
MINOR=`grep 'set(VERSION_MINOR' ./CMakeLists.txt | sed -e 's/set(VERSION_MINOR \"\([0-9a-z\.]\+\)\")/\1/g'`
PATCH=`grep 'set(VERSION_PATCH' ./CMakeLists.txt | sed -e 's/set(VERSION_PATCH \"\([0-9a-z\.]\+\)\")/\1/g'`
echo "Current version is $MAJOR.$MINOR.$PATCH"
PATCH=$(($PATCH+1))
echo "New version will be $MAJOR.$MINOR.$PATCH"
TEST="false"
elif [ "$#" -ne "3" ]
then
echo "Improper version number supplied (use 'changeversion MAJOR MINOR PATCH', 'bump' to increase patch number, or no args to check existing files)"
exit 1
else
MAJOR=$1
MINOR=$2
PATCH=$3
TEST="false"
echo "Changing version numbers in files (to ${MAJOR}.${MINOR}.{$PATCH}..."
fi
# Program (version.h)
if [ "$TEST" = "false" ]
then
#cp src/main/version.h src/main/version.h.orig
sed -i -e "s/#define DISSOLVEVERSION \"[0-9\.]\+\(.*\)\"/#define DISSOLVEVERSION \"$MAJOR.$MINOR.$PATCH\"\1/g" src/version.h
fi
echo -n " version.h (Program Version) : "
grep '#define DISSOLVEVERSION' src/version.h | sed -e 's/#define DISSOLVEVERSION "\([0-9a-z\.]\+\).*"/\1/g'
# ./CMakeLists.txt
if [ "$TEST" = "false" ]
then
sed -i -e "s/set(VERSION_MAJOR \"\([0-9\.]\+\)\")/set(VERSION_MAJOR \"$MAJOR\")/g" -e "s/set(VERSION_MINOR \"\([0-9a-z\.]\+\)\")/set(VERSION_MINOR \"$MINOR\")/g" -e "s/set(VERSION_PATCH \"\([0-9a-z\.]\+\)\")/set(VERSION_PATCH \"$PATCH\")/g" CMakeLists.txt
fi
echo -n " ./CMakeLists.txt (Major Version) : "
grep 'set(VERSION_MAJOR' ./CMakeLists.txt | sed -e 's/set(VERSION_MAJOR \"\([0-9a-z\.]\+\)\")/\1/g'
echo -n " (Minor Version) : "
grep 'set(VERSION_MINOR' ./CMakeLists.txt | sed -e 's/set(VERSION_MINOR \"\([0-9a-z\.]\+\)\")/\1/g'
echo -n " (Patch Version) : "
grep 'set(VERSION_PATCH' ./CMakeLists.txt | sed -e 's/set(VERSION_PATCH \"\([0-9a-z\.]\+\)\")/\1/g'
# OSX build files
if [ "$TEST" = "false" ]
then
sed -i -e "s/APP_VERSION=\"\([0-9a-z\.]\+\)\"/APP_VERSION=\"$MAJOR.$MINOR.$PATCH\"/g" ./ci/osx/dissolve.dmginfo
sed -i -e "s/APP_VERSION=\"\([0-9a-z\.]\+\)\"/APP_VERSION=\"$MAJOR.$MINOR.$PATCH\"/g" ./ci/osx/dissolve-gui.dmginfo
sed -i -e "s/APP_VERSION=\"\([0-9a-z\.]\+\)\"/APP_VERSION=\"$MAJOR.$MINOR.$PATCH\"/g" ./ci/osx/dissolve-mpi.dmginfo
fi
echo -n " dissolve.dmginfo (Program Version) : "
grep 'APP_VERSION=' ./ci/osx/dissolve.dmginfo | sed -e 's/APP_VERSION=\"\([0-9a-z\.]\+\)\"/\1/g'
echo -n "dissolve-gui.dmginfo (Program Version) : "
grep 'APP_VERSION=' ./ci/osx/dissolve-gui.dmginfo | sed -e 's/APP_VERSION=\"\([0-9a-z\.]\+\)\"/\1/g'
echo -n "dissolve-mpi.dmginfo (Program Version) : "
grep 'APP_VERSION=' ./ci/osx/dissolve-mpi.dmginfo | sed -e 's/APP_VERSION=\"\([0-9a-z\.]\+\)\"/\1/g'
# Windows build files
if [ "$TEST" = "false" ]
then
sed -i -e "s/#define MyAppVersion \"[0-9\.]*\"/#define MyAppVersion \"$MAJOR.$MINOR.$PATCH\"/g" -e "s/OutputBaseFilename=Dissolve-GUI-[0-9\.]*-Win64/OutputBaseFilename=Dissolve-GUI-$MAJOR.$MINOR.$PATCH-Win64/g" ci/windows/dissolve-gui.iss
fi
echo -n " dissolve-gui.iss (Program Version) : "
grep 'define MyAppVersion' ci/windows/dissolve-gui.iss | sed -e 's/#define MyAppVersion \"\([0-9\.]*\)\"/\1/g'
echo -n " dissolve-gui.iss (Output Filename) : "
grep 'OutputBaseFilename' ci/windows/dissolve-gui.iss | sed -e 's/OutputBaseFilename=Dissolve-GUI-\([0-9\.]*\)-Win64/\1/g'
# Documentation
if [ "$TEST" = "false" ]
then
DAYSUFFIX=`DaySuffix`
TODAY=`date "+%A %-d${DAYSUFFIX} %B %Y"`
sed -i -e "s/Current Version: [0-9\.]*, \(.*\)_/Current Version: $MAJOR.$MINOR.$PATCH, ${TODAY}_/g" docs/index.md
fi
echo -n " Documentation (Program Version) : "
grep 'Current Version:' docs/index.md | sed -e 's/.*Version: \([0-9\.]*\),.*/\1/g'
echo -n " Documentation (Date) : "
grep 'Current Version:' docs/index.md | sed -e "s/.*Version: .*, \(.*\)_/\1/g"
# README.md
if [ "$TEST" = "false" ]
then
DAYSUFFIX=`DaySuffix`
TODAY=`date "+%A %-d${DAYSUFFIX} %B %Y"`
sed -i -e "s/Current Version: [0-9\.]*, \(.*\)_/Current Version: $MAJOR.$MINOR.$PATCH, ${TODAY}_/g" README.md
fi
echo -n " README.md (Program Version) : "
grep 'Current Version:' README.md | sed -e 's/.*Version: \([0-9\.]*\),.*/\1/g'
echo -n " README.md (Date) : "
grep 'Current Version:' README.md | sed -e "s/.*Version: .*, \(.*\)_/\1/g"
exit 0