-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrelease.sh
executable file
·60 lines (47 loc) · 1.32 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
#!/bin/bash
set -o errexit
echoerr() { echo "$@" 1>&2; }
if [ $# -lt 3 ]; then
echoerr "Usage: release.sh <repo> <version> <files>"
exit 1
fi
repo=$1
new_version=$2
shift; shift
files=$@
if ! grep $new_version ./RELEASE_NOTES.md; then
echoerr "RELEASE_NOTES does not contain a section for $new_version"
exit 1
fi
description=$(awk "/^#.*$new_version/{flag=1;next}/^#/{flag=0}flag" ./RELEASE_NOTES.md)
if ! git diff --quiet HEAD; then
echoerr "Cannot create release with a dirty repo."
echoerr "Commit or stash changes and try again."
git status -sb
exit 1
fi
sed -i.bak -E "s/v[0-9]\.[0-9]\.[0-9]/$new_version/g" README.md
sed -i.bak -E "s/v[0-9]\.[0-9]\.[0-9]/$new_version/g" version.go
git add README.md version.go
git commit -am "Changed version to $new_version"
git tag $new_version -am "Release $new_version"
rm README.md.bak version.go.bak
git push --tags
echo "Create Release $new_version"
github-release release \
--user andersjanmyr \
--repo $repo \
--tag $new_version \
--name "Release $new_version" \
--description "$description"
echo "Upload assets $files"
for f in $files; do
echo "Upload $f as ${f#*/}"
github-release upload \
--user andersjanmyr \
--repo $repo \
--tag $new_version \
--name "${f#*/}" \
--file "$f"
done
echo "Update Homebrew formula"