forked from openmetaearth/meta-earth
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease-note.sh
More file actions
36 lines (28 loc) · 963 Bytes
/
Copy pathrelease-note.sh
File metadata and controls
36 lines (28 loc) · 963 Bytes
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
#!/usr/bin/env bash
set -o errexit -o nounset
function find_change_log() {
local file="$1"
local version="$2"
local i
i="$(grep -n "\[$version\]" "$file" | cut -d: -f1 | head -n 1)"
if [[ -z "$i" ]]; then
echo "cannot find version $version" >&2 && return
fi
local j
j="$(tail -n +"$i" "$file" | grep -n "\-\-\-" | cut -d: -f1 | head -n 1)"
if [[ -z "$j" ]]; then
echo "cannot find the end of $version's changelog" >&2 && exit 1
fi
tail -n +"$i" "$file" | head -n "$j"
}
version=${1:-$VERSION}
changelog="$(find_change_log "./CHANGELOG.md" "$version")"
last_version=$(git tag --sort=-creatordate | grep -v '/' | head -n 2 | tail -n 1 || true)
echo "writing release note for version $version"
cat <<EOF >./release-note.md
<!-- Add upgrade instructions here -->
## 🚀 Highlights
<!-- Add any highlights of this release -->
$changelog
**Full Changelog**: https://github.com/st-chain/me-hub/compare/$last_version...$version.
EOF