-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmkvi.sh
More file actions
30 lines (25 loc) · 857 Bytes
/
mkvi.sh
File metadata and controls
30 lines (25 loc) · 857 Bytes
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
#!/usr/bin/env sh
# Generates a mk2.vi file, containing the current version information about the
# deployed mk2
# Requires git to allow access to the repository (same user)
# get tag data from git
last_tag_data=$(git tag --sort="-v:refname" --format "%(objectname:short) %(refname:short)" | head -1)
last_tag_sha=$(echo "$last_tag_data" | cut -d ' ' -f 1)
last_tag=$(echo "$last_tag_data" | cut -d ' ' -f 2)
# get commit data from git
last_commit_data=$(git log HEAD -n 1 --pretty="format:%h on %cI")
last_commit_sha=$(echo "$last_commit_data" | cut -d ' ' -f 1)
# output
rm -f mk2.vi
touch mk2.vi
chmod 644 mk2.vi
if [ "$last_tag_sha" = "$last_commit_sha" ]
then
echo "release" >> mk2.vi
echo "$last_tag" >> mk2.vi
else
echo "rolling patch" >> mk2.vi
echo "patch of $last_tag" >> mk2.vi
fi
echo "$last_commit_data" >> mk2.vi
chmod 444 mk2.vi