scripts/release-notes: Support patch releases

This also fixes the broken case statement, which has globs, not regexes.
This commit is contained in:
Robert Hensing 2023-11-19 18:13:59 +01:00
parent 2a538c571b
commit b1ea30f21d
2 changed files with 71 additions and 18 deletions

View File

@ -150,6 +150,30 @@ release:
## Creating a point release ## Creating a point release
* Checkout.
```console
$ git checkout XX.YY-maintenance
```
* Determine the next patch version.
```console
$ export VERSION=XX.YY.ZZ
```
* Update release notes.
```console
$ ./scripts/release-notes
```
* Push.
```console
$ git push
```
* Wait for the desired evaluation of the maintenance jobset to finish * Wait for the desired evaluation of the maintenance jobset to finish
building. building.

View File

@ -89,14 +89,40 @@ if [[ ! -n "${VERSION:-}" ]]; then
exit 1 exit 1
fi fi
case "$VERSION" in # mutate/initialize:
# FIXME: accepts "." without any real digits # VERSION: MAJOR.MINOR
[[:digit:]]*.[[:digit:]]*) # FULL_VERSION: MAJOR.MINOR.PATCH
;; # IS_PATCH: true if this is a patch release; append instead of create
*) if grep -E '^[0-9]+\.[0-9]+$' <<< "$VERSION" >/dev/null; then
die "VERSION must be MAJOR.MINOR, where each is a number, e.g. 2.20 (VERSION was set to $VERSION)" log 'is minor'
;; IS_PATCH=false
esac FULL_VERSION="$VERSION.0"
elif grep -E '^[0-9]+\.[0-9]+\.0$' <<< "$VERSION" >/dev/null; then
log 'is minor (.0)'
IS_PATCH=false
FULL_VERSION="$VERSION"
VERSION="$(echo "$VERSION" | sed -e 's/\.0$//')"
elif grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' <<< "$VERSION" >/dev/null; then
log 'is patch'
IS_PATCH=true
FULL_VERSION="$VERSION"
VERSION="$(echo "$VERSION" | sed -e 's/\.[0-9]*$//')"
else
die "VERSION must be MAJOR.MINOR[.PATCH], where each is a number, e.g. 2.20 or 2.20.1 (VERSION was set to $VERSION)"
fi
log "VERSION=$VERSION"
log "FULL_VERSION=$FULL_VERSION"
log "IS_PATCH=$IS_PATCH"
basename=rl-$VERSION.md
file=doc/manual/src/release-notes/$basename
if ! $IS_PATCH; then
if [[ -e $file ]]; then
die "release notes file $file already exists. If you'd like to make a minor release, pass a patch version, e.g. 2.20.1"
fi
fi
# --- DEFAULTS --- # --- DEFAULTS ---
@ -106,7 +132,7 @@ if [[ ! -n "${DATE:-}" ]]; then
fi fi
case "$DATE" in case "$DATE" in
[[:digit:]]*-[[:digit:]]*-[[:digit:]]*) [0-9]*-[0-9]*-[0-9]*)
;; ;;
*) *)
die "DATE must be YYYY-MM-DD, e.g. 2021-12-31 (DATE was set to $DATE)" die "DATE must be YYYY-MM-DD, e.g. 2021-12-31 (DATE was set to $DATE)"
@ -115,25 +141,28 @@ esac
# --- DO THE WORK --- # --- DO THE WORK ---
basename=rl-$VERSION.md # menu
file=doc/manual/src/release-notes/$basename
title="Release $VERSION ($DATE)" title="Release $VERSION ($DATE)"
# section on page
section_title="Release $FULL_VERSION ($DATE)"
( (
# TODO add minor number, and append? # TODO add minor number, and append?
echo "# $title" echo "# $section_title"
echo echo
changelog-d doc/manual/rl-next | sed -e 's/ *$//' changelog-d doc/manual/rl-next | sed -e 's/ *$//'
) > $file ) | tee -a $file
log "Wrote $file" log "Wrote $file"
NEW_SUMMARY_LINE=" - [$title](release-notes/$basename)" if ! $IS_PATCH; then
NEW_SUMMARY_LINE=" - [$title](release-notes/$basename)"
# find the marker line, insert new link after it # find the marker line, insert new link after it
escaped_marker="$(echo "$SUMMARY_MARKER_LINE" | sed -e 's/\//\\\//g' -e 's/ /\\ /g')" escaped_marker="$(echo "$SUMMARY_MARKER_LINE" | sed -e 's/\//\\\//g' -e 's/ /\\ /g')"
escaped_line="$(echo "$NEW_SUMMARY_LINE" | sed -e 's/\//\\\//g' -e 's/ /\\ /g')" escaped_line="$(echo "$NEW_SUMMARY_LINE" | sed -e 's/\//\\\//g' -e 's/ /\\ /g')"
logcmd sed -i -e "/$escaped_marker/a $escaped_line" doc/manual/src/SUMMARY.md.in logcmd sed -i -e "/$escaped_marker/a $escaped_line" doc/manual/src/SUMMARY.md.in
fi
for f in doc/manual/rl-next/*.md; do for f in doc/manual/rl-next/*.md; do
if [[ config != "$(basename $f)" ]]; then if [[ config != "$(basename $f)" ]]; then