forked from disorderedmaterials/dissolve
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchangeversion
More file actions
executable file
·177 lines (153 loc) · 6.14 KB
/
changeversion
File metadata and controls
executable file
·177 lines (153 loc) · 6.14 KB
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#!/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
}
usage() {
echo "Usage: $0 [-c] [-p] [-m] [-i] [-r] [-d] [-s X.Y.Z]"
echo " -c Check current version numbering"
echo " -M Increase major version number (X.0.0)"
echo " -m Increase minor version number (0.X.0)"
echo " -p Increase patch version number (0.0.X)"
echo " -s Set version explicitly to X.Y.Z"
echo " -r Release version - modify release version in web config (and date in README.md) only"
echo " -d Development version - modify development version in web config only"
echo ""
echo "Default behaviour is to change version numbering in code, and installer and packaging scripts."
echo "Web-visible values can be changed with the -r and -d switches."
}
# Check for no args provided
if [ $# == 0 ]
then
usage
exit 1
fi
# Get current 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')
CHECK="false"
TYPE="CODE" # CODE / RELEASE / DEVELOP
while getopts ":cdmMiprs:" opt
do
case $opt in
c) CHECK="true"
echo "Current version numbers will be checked - no modifications will be made"
;;
M) echo "Major version number will be increased from $MAJOR to $((MAJOR+1))"
MAJOR=$((MAJOR+1))
MINOR=0
PATCH=0
;;
m) echo "Minor version number will be increased from $MINOR to $((MINOR+1))"
MINOR=$((MINOR+1))
PATCH=0
;;
p) echo "Minor version number will be increased from $PATCH to $((PATCH+1))"
PATCH=$((PATCH+1))
;;
s) MAJOR=$(echo $OPTARG | cut -f1 -d.)
MINOR=$(echo $OPTARG | cut -f2 -d.)
PATCH=$(echo $OPTARG | cut -f3 -d.)
echo "Version will be set explicitly to MAJOR=$MAJOR MINOR=$MINOR PATCH=$PATCH"
;;
r) echo "Only release version and date will be set."
TYPE="RELEASE"
;;
d) echo "Only development version will be set."
TYPE="DEVELOP"
;;
\?) usage
exit 1
;;
*) echo "Error: Extra operands given."
usage
exit 1
;;
esac
done
#########################################
# Code / Installer / Packaging Versions #
#########################################
if [ "$TYPE" = "CODE" ] || [ "$CHECK" = "true" ]
then
# Program (main/version.h)
if [ "$CHECK" = "false" ]
then
sed -i -e "s/#define DISSOLVEVERSION \"[0-9\.]\+\(.*\)\"/#define DISSOLVEVERSION \"$MAJOR.$MINOR.$PATCH\"\1/g" src/main/version.cpp
fi
echo -n " version.cpp (Program Version) : "
grep '#define DISSOLVEVERSION' src/main/version.cpp | sed -e 's/#define DISSOLVEVERSION "\([0-9a-z\.]\+\).*"/\1/g'
# ./CMakeLists.txt
if [ "$CHECK" = "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'
# Windows build files
if [ "$CHECK" = "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'
fi
##########################
# Website Version / Date #
##########################
if [ "$TYPE" = "RELEASE" ] || [ "$CHECK" = "true" ]
then
# Documentation (config.toml)
if [ "$CHECK" = "false" ]
then
sed -i -e "s/releaseVersion = \"[0-9\.]*\"/releaseVersion = \"$MAJOR.$MINOR.$PATCH\"/g" web/config.toml
DAYSUFFIX=$(DaySuffix)
TODAY=$(date "+%-d${DAYSUFFIX} %B %Y")
sed -i -e "s/releaseDate = \".*\"/releaseDate = \"${TODAY}\"/g" web/config.toml
fi
echo -n " config.toml (Release Version) : "
grep 'releaseVersion' web/config.toml | sed -e 's/releaseVersion = "\([0-9\.]*\)"/\1/g'
echo -n " config.toml (Release Date) : "
grep 'releaseDate' web/config.toml | sed -e 's/releaseDate = "\(.*\)"/\1/g'
fi
if [ "$TYPE" = "DEVELOP" ] || [ "$CHECK" = "true" ]
then
# Documentation (config.toml)
if [ "$CHECK" = "false" ]
then
sed -i -e "s/devVersion = \"[0-9\.]*\"/devVersion = \"$MAJOR.$MINOR.$PATCH\"/g" web/config.toml
fi
echo -n " config.toml (Develop Version) : "
grep 'devVersion' web/config.toml | sed -e 's/devVersion = "\([0-9\.]*\)"/\1/g'
fi
#############
# README.md #
#############
if [ "$TYPE" = "RELEASE" ] || [ "$CHECK" = "true" ]
then
# README.md
if [ "$CHECK" = "false" ]
then
DAYSUFFIX=$(DaySuffix)
TODAY=$(date "+%A %-d${DAYSUFFIX} %B %Y")
sed -i -e "s/Last Release: [0-9\.]*, \(.*\)_/Last Release: $MAJOR.$MINOR.$PATCH, ${TODAY}_/g" README.md
fi
echo -n " README.md (Release Version) : "
grep 'Last Release:' README.md | sed -e 's/.*Release: \([0-9\.]*\),.*/\1/g'
echo -n " README.md (Release Date) : "
grep 'Last Release:' README.md | sed -e "s/.*Release: .*, \(.*\)_/\1/g"
fi
exit 0