-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathrelease.sh
executable file
·87 lines (64 loc) · 2.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
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
#!/bin/bash
### Release management and changelog generation script. ###
set -e
printfln() {
printf "\n$1\n"
}
changelog() {
# NOTE: This requires github_changelog_generator to be installed.
# https://github.com/skywinder/github-changelog-generator
if [ -z "$NEXT" ]; then
NEXT="Unreleased"
fi
echo "Generating changelog upto version: $NEXT"
github_changelog_generator \
--user="leapfrogtechnology" \
--project="sync-db" \
--token="$RIBBY_GITHUB_TOKEN" \
--no-verbose \
--pr-label "**Changes**" \
--bugs-label "**Bug Fixes**" \
--issues-label "**Closed Issues**" \
--future-release="$NEXT" \
--release-branch=master \
--exclude-labels=unnecessary,duplicate,question,invalid,wontfix
}
bump() {
last_tag=$(git tag --sort=-creatordate | head -n 1)
printfln "$last_tag"
echo "Bumping the version: ${last_tag} -> ${NEXT}"
git tag "${NEXT}"
hub release create "$NEXT" -m "$NEXT" || true
}
compare_and_release() {
## Compare the package.json file from published package to master branch and export
## value to NEXT variable if it differs.
old_version=$(npm show @leapfrogtechnology/sync-db version)
printfln "Old package version: ${old_version}"
new_version=$(cat package.json | jq -r ".version")
printfln "New package version: ${new_version}"
NEXT=false
if [ "$old_version" != "$new_version" ]; then
printfln "Publishing changes to npm with version: ${new_version}"
NEXT="v${new_version}"
else
printfln "Skipping publish as package version has not changed"
fi
if [ "$NEXT" != "false" ]; then
# Update CHANGELOG.md
changelog
# Update commands and usage of CLI in README.md
yarn doc:update
git checkout master
git add CHANGELOG.md README.md
git commit -v -m "${NEXT} Release :tada: :fireworks: :bell:" -m "[skip ci]"
# Add new remote with access token in the git URL for authentication
git remote add lft https://leapfrogtechnology:${RIBBY_GITHUB_TOKEN}@github.com/leapfrogtechnology/sync-db.git
git push lft master
printfln "Changelog updated."
# Bump & release tag
bump
fi
}
# Run command received from args.
$1