This repository has been archived by the owner on Sep 2, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
release.bash
executable file
·97 lines (77 loc) · 1.86 KB
/
release.bash
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
96
97
#!/bin/bash
set -o errexit
set -o nounset
REPO_OWNER="{REPO_OWNER}"
REPO_NAME="{REPO_NAME}"
verify_args() {
echo "Cutting a release for version $version with commit $commit"
while true; do
read -rp "Is this correct (y/n)?" yn
case $yn in
[Yy]*) break;;
[Nn]*) exit;;
*) echo "Please answer y or n.";;
esac
done
}
if [ $# -le 3 ]; then
echo "GH username, GH personal access token, version, commit arguments required"
exit 1
fi
ghuser=$1
ghtoken=$2
version=$3
commit=$4
verify_args
# create version release branch
git checkout master
git pull
if ! git diff --exit-code master origin/master
then
echo "ERROR! There are local-only changes on branch 'master'!"
exit 1
fi
git checkout -b "release-$version" "$commit"
# update CHANGELOG
changelog-tool release "$version" -e
# commit CHANGELOG updates
git add CHANGELOG.md
git commit -m "Prep for $version release
[skip ci]"
# merge into master
git checkout master
if ! git diff --exit-code master origin/master
then
echo "ERROR! There are local-only changes on branch 'master'!"
exit 1
fi
git merge "release-$version" -m "Release $version"
# tag release
git tag "$version"
# push to release to remote
git push origin master
git push origin "$version"
# update CHANGELOG for new entries
changelog-tool unreleased -e
# commit changelog and push to master
git add CHANGELOG.md
git commit -m "Add unreleased section to CHANGELOG post $version release prep
[skip ci]"
git push origin master
# release body
body=$(changelog-tool get "${version}")
jsontemplate="
{
\"tag_name\":\$version,
\"name\":\$version,
\"body\":\$body
}
"
json=$(jq -n \
--arg version "$version" \
--arg body "$body" \
"${jsontemplate}")
curl -X POST "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/releases" \
-H "Content-Type: application/x-www-form-urlencoded" \
-u "${ghuser}:${ghtoken}" \
--data "${json}"