-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadd-unreleased-section.sh
More file actions
executable file
·81 lines (61 loc) · 1.07 KB
/
add-unreleased-section.sh
File metadata and controls
executable file
·81 lines (61 loc) · 1.07 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
75
76
77
78
79
80
81
#!/usr/bin/env bash
set -eo pipefail
die() {
local exit_code=1
local OPTIND=1
local opt
while getopts "c:" opt; do
case "$opt" in
c)
exit_code="$OPTARG"
;;
esac
done
shift $((OPTIND - 1))
echo "ERROR:" "$@" >&2
exit $exit_code
}
print_usage() {
cat <<EOF
Usage: ${0##*/} -h
Adds an unreleased section to the CHANGELOG.md file.
OPTIONS
EOF
sed -n '/^[[:space:]]*##:/ s// /p' "$BASH_SOURCE"
}
while getopts :h opt; do
case "$opt" in
##: -h Show this help
h)
print_usage
exit 0
;;
\?)
die -c 2 "Invalid option: -${OPTARG}"
;;
esac
done
shift $((OPTIND - 1))
cd "${BASH_SOURCE%/*}/.."
package="$1"
changelog="CHANGELOG.md"
[[ -f "$changelog" ]] || die "Changelog for ${package} not found."
ed -s "$changelog" <<'EOF'
1;/^## /i
## [Unreleased] [major|minor|patch]
### Changed
- <Describe changes>
### Removed
- <Describe removals>
### Added
- <Describe additions>
### Fixed
- <Describe fixes>
### Deprecated
- <Describe deprecations>
### Security
- <Describe security fixes>
.
w
q
EOF