forked from veskuh/qmldialer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmksnapshot
executable file
·62 lines (55 loc) · 2.13 KB
/
mksnapshot
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
#!/bin/bash
[ "${1}z" = "z" ] && {
echo "usage: $0 MAJOR.MINOR.MICRO"
exit
}
git update-index --ignore-submodules --refresh &&
git diff-files --ignore-submodules --quiet &&
git diff-index --ignore-submodules --cached --quiet HEAD -- || {
echo "can not lay new tag -- your working tree is not up-to-date"
exit
}
tag=$1
git tag -l | grep $tag && {
echo "can not lay tag -- it already exists."
echo "run 'git tag -d version-$tag' to remove."
exit
}
version=(${tag//./ })
COMMIT_FILES="ChangeLog"
# NOTE: Uses only first file that defines VERSION
PRO_FILE=$(grep -El "VERSION ?= ?[0-9]+\.[0-9]+\.[0-9]+$" *.pr[io]|head -n1)
[ "x$PRO_FILE" == "x" ] && {
# No .pr[io] files set VERSION, assume automake and change configure.ac
sed -i -e "s#_version_major, [^)]*)#_version_major, ${version[0]})#g" \
-e "s#_version_minor, [^)]*)#_version_minor, ${version[1]})#g" \
-e "s#_version_micro, [^)]*)#_version_micro, ${version[2]})#g" \
configure.ac
COMMIT_FILES="${COMMIT_FILES} configure.ac"
} || {
# At least one .pro file exisits, modify VERSION tag in first .pro file
# TODO: fix this to be smarter than just modifying first .pro file
# maybe looking for which one holds the VERSION tag?
sed -i -e "s#VERSION = .*#VERSION = ${tag}#g" $PRO_FILE
COMMIT_FILES="${COMMIT_FILES} $PRO_FILE"
}
export $(grep -e "^PROJECT=\".*\"" makedist)
YAML_FILE="${PROJECT//\"/}.yaml"
[ "x$YAML_FILE" == "x" ] || {
# modify Version tag in the .yaml file to match the version we're
# tagging for this snapshot
sed -i -e "s#Version: .*#Version: ${tag}#g" $YAML_FILE
COMMIT_FILES="${COMMIT_FILES} $YAML_FILE"
}
echo -e "Changes in ${tag}\n" > ChangeLog.tmp &&
git log --pretty=oneline --abbrev=3 --abbrev-commit -r $(git describe --tags --abbrev=0).. >> ChangeLog.tmp &&
echo "" >> ChangeLog.tmp &&
cat ChangeLog >> ChangeLog.tmp &&
mv ChangeLog.tmp ChangeLog &&
git commit -s $COMMIT_FILES -m "Updated release files to version $tag" > /dev/null &&
git tag version-$tag && {
echo "Version set to $tag and tag laid."
echo "Make sure to 'git-push --tags' if you want to distribute."
} || {
echo "Version update failed. Reason unknown. Try git-diff."
}