-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrelease-notes.sh
More file actions
executable file
·74 lines (62 loc) · 1.48 KB
/
Copy pathrelease-notes.sh
File metadata and controls
executable file
·74 lines (62 loc) · 1.48 KB
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
#!/usr/bin/env bash
set -euo pipefail
if [ "$#" -ne 2 ]; then
echo "usage: $0 <tag> <output-file>" >&2
exit 2
fi
tag="$1"
output_file="$2"
case "$tag" in
v[0-9]*.[0-9]*.[0-9]*)
version="${tag#v}"
base_version="${version%%-*}"
;;
*)
echo "release tag must use vX.Y.Z or vX.Y.Z-prerelease format: $tag" >&2
exit 1
;;
esac
declared_version="$(tr -d '[:space:]' < VERSION)"
if [ "$base_version" != "$declared_version" ]; then
echo "release tag $tag does not match VERSION $declared_version" >&2
exit 1
fi
if [ "$version" != "$base_version" ]; then
cat > "$output_file" <<EOF
Release candidate for \`v$base_version\`.
This prerelease is intended to validate release packaging and platform artifacts.
See the final \`v$base_version\` release for changelog notes.
EOF
exit 0
fi
awk -v version="$base_version" -v tag="$tag" '
$0 ~ "^## \\[" version "\\]" {
found = 1
first = 1
date = $0
sub("^## \\[" version "\\] - ", "", date)
print "## gitfleet@" tag " | " date
print ""
next
}
found && /^## \[/ {
exit
}
found {
if (first && $0 == "") {
first = 0
next
}
first = 0
print
}
END {
if (!found) {
exit 1
}
}
' CHANGELOG.md > "$output_file"
if [ ! -s "$output_file" ]; then
echo "CHANGELOG.md section for $version is empty or missing" >&2
exit 1
fi