-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
npm_publish.sh
executable file
·68 lines (59 loc) · 1.4 KB
/
npm_publish.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
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
# Exit if one of the commands fail
set -e
if [[ "$GITHUB_TOKEN" = "" ]]
then
echo 'Aborting script. No GITHUB_TOKEN env variable found.';
exit 1;
fi
# Get first parameter
OPT="$1";
if [[ "$OPT" != "" ]]
then
case "$OPT" in
"patch")
OPT="patch"
;;
"minor")
OPT="minor"
;;
"major")
OPT="major"
;;
*)
echo >&2 "Invalid option: $@"; exit 1
;;
esac
else
OPT="patch"
fi
# Check if the current version is master
BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ "$BRANCH" != "master" ]]
then
echo 'Aborting script. You are not in master branch';
exit 1;
fi
# Bump version
npm version $OPT
TAG=$(git tag --points-at HEAD)
git tag -d $TAG
cd src && npm version $OPT
cd .. && git commit -a --amend --no-edit
git tag $TAG
git push origin master $TAG # push to create CHANGELOG
# Update CHANGELOG
docker run -it --rm -v "$(pwd)":/usr/local/src/your-app ferrarimarco/github-changelog-generator --user workylab --project materialize-angular --token ${GITHUB_TOKEN} --exclude-labels 'duplicate,question,invalid,wontfix,nochangelog,release'
git add CHANGELOG.md
git commit -m "Update CHANGELOG for $TAG [skip ci]"
# Retag version
git tag -d $TAG
git push origin :refs/tags/$TAG
git tag $TAG
git push origin master $TAG
# Merge back
echo "Merge backing from master to dev..."
git checkout dev
git pull origin dev
git rebase master
git push origin dev