-
Notifications
You must be signed in to change notification settings - Fork 8
/
release.sh
executable file
·78 lines (63 loc) · 1.79 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
#!/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 ! [[ "$new_version" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echoerr "Usage: version must follow pattern vN.N.N: $new_version"
exit 1
fi
check_github_release_config() {
if ! github-release edit \
--user andersjanmyr \
--repo route53copy \
--tag v1.0.0 \
--name "Release 1.0.0" ; then
echoerr "github release must be installed and configured"
echoerr "https://github.com/aktau/github-release#how-to-install"
exit 1
fi
}
# check_github_release_config
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"