This repository has been archived by the owner on Jul 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
makerelease
executable file
·95 lines (80 loc) · 3.39 KB
/
makerelease
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
# Usage: makerelease (tag|update) <project>
#
# Script for creating tags in a standard format interactively.
set -e
source "$(git rev-parse --show-toplevel)/DevOps/frankfurter/scripts/tools/env"
function get_shepherd_version {
bash -c "cd '$piecentral/shepherd' && pipenv run python3 Shepherd.py --version"
}
function get_runtime_version {
bash -c "cd '$piecentral/runtime' && pipenv run python3 runtime.py --version"
}
function get_dawn_version {
cat "${piecentral}/dawn/package.json" | python -c 'import sys, json; print(json.load(sys.stdin)["version"])'
}
function set_runtime_version {
bash -c "cd '$piecentral/runtime' && sed -i -e 's/^__version__\s*=\s*.*$/__version__ = ($1, $2, $3)/g' runtimeUtil.py"
}
function set_shepherd_version {
bash -c "cd '$piecentral/shepherd' && sed -i -e 's/^__version__\s*=\s*.*$/__version__ = ($1, $2, $3)/g' Shepherd.py"
}
function set_dawn_version {
bash -c "cd '$piecentral/dawn' && sed -i -e 's/\"version\":\s*\".*\",$/\"version\": \"$1.$2.$3\",/g' package.json"
}
cmd="$1"
project="$2"
usage="Usage: $0 (update|tag|help) [options]
Commands:
update <project> Interactively increment a version number according to
semantic versioning. The updated version number is written
back to the file where the version number for a project is
stored. You must add and commit this change before merging
a feature branch.
tag <project> Use the project's version number to tag the current commit
with a standard name. You should use this after a feature
branch has been merged into master to trigger a release
from Travis. You will need to push the newly generated tag
yourself.
help Display this help message."
if [ "$cmd" != 'tag' ] && [ "$cmd" != 'update' ] || [ ! "$project" ] || [ "$cmd" = 'help' ]; then
echo "$usage"
exit 1
elif [ ! -d "$project" ]; then
echo -e $red"Error: '$1' is not a project."$clear
exit 2
fi
semver_pattern='[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+'
if [ "$cmd" = 'tag' ]; then
if [ $(git symbolic-ref --short HEAD) != "master" ]; then
echo -e $yellow"Warning: you are not on the 'master' branch."$clear
fi
now=$(date +%Y-%m-%dT%H%M%S)
tag="$project/$(get_"$project"_version)-$now"
git tag "$tag"
echo -e $green"Created tag: $tag"$clear
else
last_release=$(get_"$project"_version)
echo -e $blue"Last release of '$project' was: $last_release"$clear
last_number_pattern='[[:digit:]]+$'
patch=$(echo "$last_release" | grep -Eo "$last_number_pattern")
minor=$(echo "$last_release" | grep -Eo "^[[:digit:]]+\.[[:digit:]]+" | grep -Eo "$last_number_pattern")
major=$(echo "$last_release" | grep -Eo "^[[:digit:]]+")
if [ $(prompt "Increment patch version number?") ]; then
patch=$((patch + 1))
elif [ $(prompt "Increment minor version number?") ]; then
minor=$((minor + 1))
patch='0'
elif [ $(prompt "Increment major version number?") ]; then
echo -e $yellow"Remember that major version changes are reserved for backwards-incompatible changes."$clear
major=$((major + 1))
minor='0'
patch='0'
fi
echo "Next release: $major.$minor.$patch"
if [ $(prompt "Confirm release number?") ]; then
set_"$project"_version "$major" "$minor" "$patch"
else
echo -e $red"Next release number rejected. Aborting."$clear
fi
fi