forked from open-policy-agent/opa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen-release-patch.sh
executable file
·67 lines (53 loc) · 1.09 KB
/
gen-release-patch.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
#!/usr/bin/env bash
set -e
OPA_DIR=/go/src/github.com/open-policy-agent/opa
usage() {
echo "gen-release-patch.sh --source-url=<git-url>"
echo " --version=<mj.mn.pt>"
}
for i in "$@"; do
case $i in
--source-url=*)
SOURCE_URL="${i#*=}"
shift
;;
--version=*)
VERSION="${i#*=}"
shift
;;
*)
usage
exit 1
;;
esac
done
if [ -z "$SOURCE_URL" ]; then
usage
exit 1
elif [ -z "$VERSION" ]; then
usage
exit 1
fi
git clone $SOURCE_URL $OPA_DIR
cd $OPA_DIR
if [ -z "$LAST_VERSION" ]; then
LAST_VERSION=$(git describe --abbrev=0 --tags)
fi
update_makefile() {
sed -i='' -e "s/^VERSION[ \t]*:=[ \t]*.\+$/VERSION := $VERSION/" Makefile
}
update_changelog() {
cat >_CHANGELOG.md <<EOF
$(awk '1;/## Unreleased/{exit}' CHANGELOG.md | sed '$d')
## $VERSION
$(./build/changelog.py $LAST_VERSION HEAD)
$(sed '1,/## Unreleased/d' CHANGELOG.md)
EOF
mv _CHANGELOG.md CHANGELOG.md
}
main() {
update_makefile
update_changelog
git --no-pager diff --no-color
}
main