-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
setversion.sh
executable file
·27 lines (22 loc) · 1005 Bytes
/
setversion.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
#!/bin/bash
get_version() {
local date=$(date -u -d "+12 hours" +"%Y-%m-%dT%H:%M:%S%z") # NZST date and time
local week_number=$(get_week_number "$date")
local version=$(date -u -d "$date" +"%y.%m.")$week_number
echo "$version"
}
get_week_number() {
local date="$1"
local first_day_of_month=$(date -d "$date" +%Y-%m-01)
local first_day_of_week="Monday"
# Find the first day of the week that falls on or before the first day of the month
while [[ $(date -d "$first_day_of_month" +%A) != "$first_day_of_week" ]]; do
first_day_of_month=$(date -d "$first_day_of_month - 1 day" +%Y-%m-%d)
done
local week_number=$((($(date -d "$date" +%s) - $(date -d "$first_day_of_month" +%s)) / (60 * 60 * 24 * 7) + 1))
echo "$week_number"
}
versionNumber=$(get_version)
gitversion=`cat gitversion.txt`
sed -i "s/BuildNumber = \"[^\"]*\"/BuildNumber = \"${gitversion}\"/g" Globals.cs
sed -i "s/VersionNumber = \"[^\"]*\"/VersionNumber = \"${versionNumber}\"/g" Globals.cs