forked from PerplexDigital/Perplex.ContentBlocks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
version
32 lines (22 loc) · 827 Bytes
/
version
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
#!/bin/bash
version=$1
if [ -z "$version" ]; then
echo -e "Usage: ./version <version>\n\ne.g. ./version 1.2.3-rc1"
exit;
fi
# Version without suffix. E.g. 1.2.3-rc1 becomes 1.2.3
version_info=$(echo $1 | sed 's/-.*//')
# Save any open work
git stash > /dev/null 2>&1
projectDir=src/Perplex.ContentBlocks
# Update version
# AssemblyInfo: x.y.z
sed -i "s/^\(\[assembly: AssemblyVersion(\"\)[^\"]\+/\1${version_info}/g" $projectDir/Properties/AssemblyInfo.cs
# AssemblyInformationalVersion: x.y.z
sed -i "s/^\(\[assembly: AssemblyInformationalVersion(\"\)[^\"]\+/\1${version}/g" $projectDir/Properties/AssemblyInfo.cs
# Add
git add $projectDir/Properties/AssemblyInfo.cs > /dev/null 2>&1
# Commit
git commit -m "Version ${version}" > /dev/null 2>&1
# Restore previous work
git stash pop --index > /dev/null 2>&1