-
Notifications
You must be signed in to change notification settings - Fork 0
/
release
executable file
·54 lines (42 loc) · 1.5 KB
/
release
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
#! /bin/sh
if [ "$1" = "--help" ] || [ "$1" = "-h" ] || [ "$1" = "help" ] || [ -z "$1" ]; then
cat <<EOF
$ release TYPE
Release a new version
Parameters:
\$1: one of major, minor, patch
Example:
$ release patch
EOF
exit
fi
command -v npm >/dev/null || { echo "npm is not installed" 1>&2; exit 127; }
command -v $BROWSER >/dev/null || { echo "$BROWSER was not found" 1>&2; exit 127; }
if [ "$1" != "major" ] && [ "$1" != "minor" ] && [ "$1" != "patch" ]; then
echo "\$1 has to be one of: major, minor, patch"
exit 1
fi
VERSION="$(npm --no-git-tag-version version $1)"
echo "Releasing '$VERSION'"
# track changes to release relevant files only here
git update-index --no-assume-unchanged npm-shrinkwrap.json
npm shrinkwrap
git add npm-shrinkwrap.json package.json
git commit -m $VERSION
git tag $VERSION
git push origin
git push origin --tags
# ignore for development
git update-index --assume-unchanged npm-shrinkwrap.json
# create changelog
REPO=jneidel/oraclett
URL="https://github.com/$REPO/releases/new?tag=$VERSION&title=$VERSION&body=%23%23%20Improvements%0A%0A%0A%0A%23%23%20Fixes%0A%0A%0A%0A"
LATEST=$(git tag | tail -n1)
git log $LATEST..HEAD --oneline --no-decorate | {
while read line; do
COMMIT_LINE=`echo $line | awk '{ REPO = ENVIRON["REPO"]; print "- ["substr($0, index($0," ")+1)"](https://github.com/"REPO"/commit/"$1")" }'`
ENCODED_COMMIT_LINE=`node -e "console.log( encodeURIComponent( '$COMMIT_LINE' ) )"`
URL="${URL}${ENCODED_COMMIT_LINE}%0A"
done
$BROWSER "$URL" 2>/dev/null
}