88 ~~~~~~~~~~~~~~~
99'
1010
11+ function fnApplyVersion() {
12+ : '
13+ Updates the files in the project which reference the project version.
14+ This function expects each file to have a corresponding .template file
15+ which contains the $VERSION* vars to be substituted.
16+ '
17+ local files=(
18+ OpenChart/OpenChart.csproj
19+ OpenChart/installer/win-x64/setup.isl
20+ )
21+
22+ export VERSION VERSION_MAJOR VERSION_MINOR VERSION_PATCH
23+
24+ # Update the version across the project files.
25+ for f in " ${files[@]} " ; do
26+ if [[ ! -e " $f .template" ]]; then
27+ echo " WARNING: Template file is missing at: $f .template"
28+ else
29+ envsubst < $f .template > $f
30+ echo " Updated $f .template --> $f "
31+ fi
32+ done
33+ }
34+
1135function fnBuild() {
1236 : '
1337 Builds OpenChart in debug mode.
@@ -137,6 +161,11 @@ function fnVersion() {
137161 exit
138162 ;;
139163
164+ apply)
165+ fnApplyVersion
166+ exit
167+ ;;
168+
140169 major)
141170 VERSION_MAJOR=$(( VERSION_MAJOR + 1 ))
142171 VERSION_MINOR=0
@@ -158,22 +187,21 @@ function fnVersion() {
158187 echo " COMMANDS"
159188 echo " If no command is given, prints the current version."
160189 echo
190+ echo " apply Applies the current version to any files which depend on it"
161191 echo " major Increments the major version"
162192 echo " minor Increments the minor version"
163193 echo " patch Increments the patch version"
164194 echo
195+ exit
165196 ;;
166197 esac
167198
168- # Write to the VERSION file .
199+ # Update the version .
169200 export VERSION=$VERSION_MAJOR .$VERSION_MINOR .$VERSION_PATCH
170-
171201 echo $VERSION > VERSION
172202 echo " Incremented version to $VERSION "
173203
174- # Update the version across the project files.
175- envsubst < OpenChart/OpenChart.csproj.template > OpenChart/OpenChart.csproj
176- envsubst < OpenChart/installer/win-x64/setup.isl.template > OpenChart/installer/win-x64/setup.isl
204+ fnApplyVersion
177205}
178206
179207function fnUsage() {
0 commit comments