forked from rbei-etas/busmaster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-version-information.sh
70 lines (56 loc) · 2.59 KB
/
update-version-information.sh
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
#!/bin/sh
# Usage
if [ $# -ne 1 ]; then
echo "Usage: update-version-information.sh <X.Y.Z>"
exit 1
fi
# Set version information
VERSION=$1
VERSION_MAJOR=`echo $VERSION | awk 'BEGIN { FS = "\." } ; { print $1 }'`
VERSION_MINOR=`echo $VERSION | awk 'BEGIN { FS = "\." } ; { print $2 }'`
VERSION_BUILD=`echo $VERSION | awk 'BEGIN { FS = "\." } ; { print $3 }'`
VERSION="$VERSION_MAJOR.$VERSION_MINOR.$VERSION_BUILD"
echo "Setting to Version $VERSION"
# Sources/BIN/Release/Changelog.txt
git log > Sources/BIN/Release/Changelog.txt
dos2unix Sources/BIN/Release/Changelog.txt
# Sources/Application/BUSMASTER.rc
echo " Sources/Application/BUSMASTER.rc"
sed -i.orig \
-e 's/^ VALUE "FileVersion", "Ver .*"$/ VALUE "FileVersion", "Ver '$VERSION'"/' \
-e 's/^ VALUE "ProductVersion", "Ver .*"$/ VALUE "ProductVersion", "Ver '$VERSION'"/' \
-e 's/^ IDS_VERSION "Ver .*"$/ IDS_VERSION "Ver '$VERSION'"/' \
Sources/Application/BUSMASTER.rc
# Sources/Application/StdAfx.h
echo " Sources/Application/StdAfx.h"
sed -i.orig \
-e 's/^const BYTE VERSION_MAJOR.*$/const BYTE VERSION_MAJOR = '$VERSION_MAJOR';/' \
-e 's/^const BYTE VERSION_MINOR.*$/const BYTE VERSION_MINOR = '$VERSION_MINOR';/' \
-e 's/^const BYTE VERSION_BUILD.*$/const BYTE VERSION_BUILD = '$VERSION_BUILD';/' \
Sources/Application/StdAfx.h
# Sources/FrameProcessor/LogObjectCAN.cpp
echo " Sources/FrameProcessor/LogObjectCAN.cpp"
sed -i.orig \
-e 's/^#define CAN_VERSION _T("\*\*\*BUSMASTER Ver .*\*\*\*")$/#define CAN_VERSION _T("***BUSMASTER Ver '$VERSION'***")/' \
Sources/FrameProcessor/LogObjectCAN.cpp
# Installation Setup/BUSMASTER INSTALL SCRIPT.nsi
echo " Installation Setup/BUSMASTER INSTALL SCRIPT.nsi"
sed -i.orig \
-e 's/^Outfile "BUSMASTER_Installer_Ver_.*\.exe"$/Outfile "BUSMASTER_Installer_Ver_'$VERSION'\.exe"/' \
"Installation Setup/BUSMASTER INSTALL SCRIPT.nsi"
# Some additional ideas, which could be interesting for debug purposes:
# Git describe
#DESCRIBE=`git describe`
#VERSION_MAJOR=`echo $DESCRIBE | awk 'BEGIN { FS = "[v\.-]" } ; { print $2 }'`
#VERSION_MINOR=`echo $DESCRIBE | awk 'BEGIN { FS = "[v\.-]" } ; { print $3 }'`
#VERSION_BUILD=`echo $DESCRIBE | awk 'BEGIN { FS = "[v\.-]" } ; { print $4 }'`
# Build date (or just look for the installer date)
# `date`
# Build environment (or just parse the binary files)
# Visual C++ version, e.g. Express 2008
# MFC version, e.g. 4.2
# ATL version, e.g. 7.1
# Git commit & tag & push
# git commit -m "Version $VERSION"
# git tag -a v$VERSION -m "Version $VERSION"
# git push --tags