-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
52 lines (38 loc) · 1.13 KB
/
release.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
#!/bin/sh
# Based on https://gist.github.com/fatmatto/9e989d582c391446dcf4bf0c8116cb6a
# Increments the project version (e.g. from 2.3.0 to 2.4.0)
# It handles stuff like
# * CHANGELOG
# * NPM package version
# * Git tags
# Calculating the new version requires to know which kind of update this is
# The default version increment is patch
# Used values: major|minor|patch where in x.y.z :
# major=x
# minor=y
# patch=z
if [ -z "$1" ]
then
versionType="patch"
else
versionType=$1
fi
# Increment version without creating a tag and a commit (we will create them later)
npm --no-git-tag-version version $versionType || exit 1
# Using the package.json version
version="$(grep '"version"' package.json | cut -d'"' -f4)"
# Build the commit
git add package.json;
git add package-lock.json;
git commit -m "📦 Release $version"
# Create an annotated tag
git tag -a $version -m "📦 Release $version"
# Gotta push them all
git push origin master --follow-tags;
# Generate changelog from commits
npx easy-changelog --out=./CHANGELOG.md;
git add CHANGELOG.md;
git commit -m "📒 Update CHANGELOG"
git push origin master
# Release it!
npm publish