-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathset_version.sh
executable file
·56 lines (49 loc) · 1.81 KB
/
set_version.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
#!/bin/bash
LEGACY_VERSION=`/bin/grep ^VERSION README.md | /bin/sed "s,^VERSION ,,"`
function v_version() {
local VVERSION=$(/usr/bin/git describe --tags | /bin/sed "s,-,.," | /bin/sed "s,-.*$,,")
if [ ! -f README.md ]
then
/bin/echo "Add a README.md file and try again."
exit 1
fi
[ -f README.md ] && /bin/sed -i "s,^Version .*$,Version $VVERSION," README.md
/bin/echo "$VVERSION"
}
function version() {
local VVERSION=$(v_version)
local VERSION=`/bin/echo $VVERSION | /bin/sed "s,^v,,"`
if [ ! -f metadata.json ] && [ ! -f Modulefile ]
then
/bin/echo "Add a metadata.json file and try again."
exit 1
fi
[ -f metadata.json ] && /bin/sed -i "s,^ \"version.*$, \"version\": \"$VERSION\"\,," metadata.json
[ -f Modulefile ] && /bin/sed -i "s,^version .*$,version '$VERSION'," Modulefile
/bin/echo "$VERSION"
}
if [ `/usr/bin/git diff README.md metadata.json | wc -l` -gt 0 ]
then
/bin/echo 'Commit or stash outstanding changes to metadata.json and README, or git checkout previous version, before release'
exit 1
fi
VVERSION=$(v_version)
VERSION=$(version)
if [ "$LEGACY_VERSION" != "$VVERSION" ]
then
/bin/echo "Use git tag to increment the minor version for new backward compatible functionality"
/bin/echo "Use git tag to increment the major version for incompatible API changes"
/bin/echo "Shall we git commit to the repository the incrementation of the version to $VVERSION [yes/NO]"
read commit_incremented_version
if [[ $commit_incremented_version == 'yes' ]]
then
/usr/bin/git commit metadata.json README.md -m"make release used to update version to $VVERSION "
VVERSION=$(v_version)
VERSION=$(version)
/usr/bin/git commit --amend metadata.json README.md Modulefile -m"make release used to update version to $VVERSION "
exit 0
else
exit 1
fi
fi
exit 0