File: generate-release-changelog.sh

package info (click to toggle)
rocq-stdlib 9.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 11,828 kB
  • sloc: python: 2,928; sh: 444; makefile: 319; javascript: 24; ml: 2
file content (43 lines) | stat: -rwxr-xr-x 1,008 bytes parent folder | download
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
#!/usr/bin/env bash

set -e
set -o pipefail

ask_confirmation() {
    read -p "Continue anyway? [y/N] " "${quick_conf[@]}" -r
    echo
    if [[ ! $REPLY =~ ^[Yy]$ ]]; then
        exit 1
    fi
}

if ! git diff --quiet; then
    echo "Warning: current tree is dirty."
    ask_confirmation
fi

changelog_entries_with_title=(doc/changelog/*/*.rst)

tmp=$(mktemp)
for f in "${changelog_entries_with_title[@]}"; do

    cat=${f%/*} # dirname
    if [[ ${f##*/} = 00000-title.rst ]]; then
        type=0
    else
        type_name=$(head -n 1 "$f" | cut -f 3 -d ' ')
        type_name=${type_name%".v\`"}
        type_name=${type_name#"\`"}
        type="1${type_name}"
    fi
    printf '%s %s %s\n' "$cat" "$type" "$f" >> "$tmp"
done

while read -r _ type f; do
    cat "$f" >> released.rst
    echo "" >> released.rst
    if ! [[ $type = 0 ]]; then git rm "$f" >> /dev/null; fi
done < <(sort "$tmp")

echo
echo "Changelog written in released.rst. Move its content to a new section in doc/sphinx/changes.rst."