| 1 |
#!/bin/zsh |
| 2 |
# -*- vim:fenc=utf-8:et:sw=2:ts=2:sts=2 |
| 3 |
# |
| 4 |
# Copyright (c) 2026 Enrico M. Crisostomo |
| 5 |
# |
| 6 |
# This program is free software; you can redistribute it and/or modify it under |
| 7 |
# the terms of the GNU General Public License as published by the Free Software |
| 8 |
# Foundation; either version 3, or (at your option) any later version. |
| 9 |
# |
| 10 |
# This program is distributed in the hope that it will be useful, but WITHOUT |
| 11 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 12 |
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 13 |
# details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU General Public License along with |
| 16 |
# this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
|
| 18 |
setopt local_options |
| 19 |
setopt local_traps |
| 20 |
unsetopt glob_subst |
| 21 |
|
| 22 |
set -o errexit |
| 23 |
set -o nounset |
| 24 |
|
| 25 |
PROGNAME=${0:t} |
| 26 |
PROGDIR=${0:A:h} |
| 27 |
|
| 28 |
. "${PROGDIR}/lib.zsh" |
| 29 |
|
| 30 |
usage() |
| 31 |
{ |
| 32 |
print -- "Usage: ${PROGNAME} [--apply] NEXT_VERSION" |
| 33 |
print |
| 34 |
print -- "Prepare version files for the next development cycle." |
| 35 |
print -- "NEXT_VERSION must be numeric X.Y.Z; this script appends -develop." |
| 36 |
} |
| 37 |
|
| 38 |
typeset -i apply=0 |
| 39 |
|
| 40 |
while (( $# > 0 )) |
| 41 |
do |
| 42 |
case "$1" in |
| 43 |
--apply) |
| 44 |
apply=1 |
| 45 |
shift |
| 46 |
;; |
| 47 |
--dry-run) |
| 48 |
apply=0 |
| 49 |
shift |
| 50 |
;; |
| 51 |
-h|--help) |
| 52 |
usage |
| 53 |
exit 0 |
| 54 |
;; |
| 55 |
--) |
| 56 |
shift |
| 57 |
break |
| 58 |
;; |
| 59 |
-*) |
| 60 |
release_die "unknown option: $1" |
| 61 |
;; |
| 62 |
*) |
| 63 |
break |
| 64 |
;; |
| 65 |
esac |
| 66 |
done |
| 67 |
|
| 68 |
(( $# == 1 )) || { |
| 69 |
usage |
| 70 |
exit 1 |
| 71 |
} |
| 72 |
|
| 73 |
next_version=$1 |
| 74 |
release_parse_version "${next_version}" |
| 75 |
|
| 76 |
[[ -z "${RELEASE_VERSION_MODIFIER}" ]] || |
| 77 |
release_die "NEXT_VERSION must be numeric X.Y.Z; got ${next_version}" |
| 78 |
|
| 79 |
develop_version="${next_version}-develop" |
| 80 |
|
| 81 |
if (( apply )) |
| 82 |
then |
| 83 |
"${PROGDIR}/prepare.zsh" --apply "${develop_version}" |
| 84 |
current_news_version=$(release_news_top_version NEWS) |
| 85 |
if [[ "${current_news_version}" != "${develop_version}" ]] |
| 86 |
then |
| 87 |
tmp_file=NEWS.tmp.$$ |
| 88 |
awk -v version="${develop_version}" ' |
| 89 |
NR == 1 { print; next } |
| 90 |
NR == 2 { |
| 91 |
print |
| 92 |
print "" |
| 93 |
print "New in " version ":" |
| 94 |
print "" |
| 95 |
next |
| 96 |
} |
| 97 |
{ print } |
| 98 |
' NEWS > "${tmp_file}" |
| 99 |
mv "${tmp_file}" NEWS |
| 100 |
print -- "Added NEWS section for ${develop_version}." |
| 101 |
fi |
| 102 |
print -- "Review the diff, then commit and push the post-release development bump." |
| 103 |
else |
| 104 |
print -- "Dry run only. These commands would prepare the next development cycle:" |
| 105 |
print -- " scripts/release/prepare.zsh --apply '${develop_version}'" |
| 106 |
print -- " ensure NEWS starts with 'New in ${develop_version}:'" |
| 107 |
print -- " git add CMakeLists.txt m4/fswatch_version.m4 m4/libfswatch_version.m4 NEWS" |
| 108 |
print -- " git commit -m 'Bump version to ${develop_version}'" |
| 109 |
print -- " git push origin master" |
| 110 |
fi |