Skip to content

Commit f6d5c37

Browse files
committed
Add script create GH release
Signed-off-by: Manuel Mendez <[email protected]>
1 parent c86e2d4 commit f6d5c37

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tooling/release.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
tag=$1
6+
if [[ -z ${tag:-} ]] || (($# != 1)); then
7+
echo 'tag must be provided as the only cli arg' >&2
8+
exit 1
9+
fi
10+
if ! git tag | grep -q "^$tag$"; then
11+
echo "$tag is not a git tag" >&2
12+
exit 1
13+
fi
14+
15+
ghnotes=$(
16+
gh api \
17+
--method POST \
18+
--header "Accept: application/vnd.github+json" \
19+
--header "X-GitHub-Api-Version: 2022-11-28" \
20+
--field "tag_name=$tag" \
21+
--jq .body \
22+
repos/{owner}/{repo}/releases/generate-notes
23+
)
24+
25+
range=$(awk -F/ 'END {print $NF}' <<<"$ghnotes")
26+
fullchangelog=$(tail -n1 <<<"$ghnotes")
27+
ghnotes=$(head -n -2 <<<"$ghnotes)")
28+
diffstat=$(git diff --stat "$range")
29+
shortlog=$(git shortlog -w0 --no-merges "$range")
30+
31+
gh release create "$tag" --notes "
32+
$ghnotes
33+
34+
$diffstat
35+
36+
$shortlog
37+
38+
$fullchangelog
39+
"

0 commit comments

Comments
 (0)