3
3
# controlled .prev-version file, automate the procedure by which we record
4
4
# the date, release-type and version string in the NEWS file. That commit
5
5
# will serve to identify the release, so apply a signed tag to it as well.
6
VERSION=2011-05-04.11 # UTC
6
VERSION=2012-08-01.09 # UTC
8
8
# Note: this is a bash script (could be zsh or dash)
10
# Copyright (C) 2009-2011 Free Software Foundation, Inc.
10
# Copyright (C) 2009-2012 Free Software Foundation, Inc.
12
12
# This program is free software: you can redistribute it and/or modify
13
13
# it under the terms of the GNU General Public License as published by
25
25
# Written by Jim Meyering
28
28
warn() { printf '%s: %s\n' "$ME" "$*" >&2; }
29
29
die() { warn "$*"; exit 1; }
35
34
Usage: $ME [OPTION...] VERSION RELEASE_TYPE
37
Run this script to perform the final pre-release NEWS update
38
in which the date, release-type and version string are recorded.
39
Commit that result with a log entry marking the release, and apply
40
a signed tag. Run it from your project's top-level directory.
36
Run this script from top_srcdir to perform the final pre-release NEWS
37
update in which the date, release-type and version string are
38
recorded. Commit that result with a log entry marking the release,
39
and apply a signed tag. Run it from your project's top-level
43
43
- you use git for version-control
44
- a version-controlled .prev-version file
44
45
- a NEWS file, with line 3 identical to this:
45
* Noteworthy changes in release ?.? (????-??-??) [?]
46
- a version-controlled .prev-version file
49
--branch BRANCH set release branch (default: master)
50
--help print this help, then exit
51
--version print version number, then exit
49
--branch=BRANCH set release branch (default: $branch)
50
-C, --builddir=DIR location of (configured) Makefile (default: $builddir)
51
--help print this help, then exit
52
--version print version number, then exit
54
55
To update NEWS and tag the beta 8.1 release of coreutils, I would run this:
58
59
Report bugs and patches to <bug-gnulib@gnu.org>.
63
year=`echo "$VERSION" | sed 's/[^0-9].*//'`
66
year=$(echo "$VERSION" | sed 's/[^0-9].*//')
66
69
Copyright (C) $year Free Software Foundation, Inc,
67
70
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
68
71
This is free software: you are free to change and redistribute it.
69
72
There is NO WARRANTY, to the extent permitted by law.
73
*) die "unrecognized option: $1";;
79
--branch) shift; branch=$1; shift ;;
83
1) help_version $1; exit 0;;
85
*) warn "Usage: $ME [OPTION...] VERSION TYPE"; exit 1;;
82
noteworthy='* Noteworthy changes in release'
83
noteworthy_stub="$noteworthy ?.? (????-??-??) [?]"
86
branch=$(git branch | sed -ne '/^\* /{s///;p;q;}')
91
# Handle --option=value by splitting apart and putting back on argv.
94
opt=$(echo "$1" | sed -e 's/=.*//')
95
val=$(echo "$1" | sed -e 's/[^=]*=//')
97
set dummy "$opt" "$val" ${1+"$@"}; shift
102
--help|--version) ${1#--};;
103
--branch) shift; branch=$1; shift ;;
104
-C|--builddir) shift; builddir=$1; shift ;;
105
--*) die "unrecognized option: $1";;
111
|| die "Usage: $ME [OPTION...] VERSION TYPE"
117
## ---------------------- ##
118
## First, sanity checks. ##
119
## ---------------------- ##
91
121
# Verify that $ver looks like a version number, and...
92
122
echo "$ver"|grep -E '^[0-9][0-9.]*[0-9]$' > /dev/null \
93
123
|| die "invalid version: $ver"
105
135
*) die "invalid release type: $type";;
108
# Extract package name from Makefile.
109
pkg=$(sed -n 's/^PACKAGE = \(.*\)/\1/p' Makefile) \
110
|| die 'failed to determine package name from Makefile'
112
# simple check: no question marks on line 3 of NEWS
113
noteworthy='* Noteworthy changes in release'
114
test "$(sed -n 3p NEWS)" = "$noteworthy ?.? (????-??-??) [?]" \
115
|| die 'line 3 of NEWS looks fishy!'
138
# No local modifications allowed.
118
139
case $(git diff-index --name-only HEAD) in
120
141
*) die 'this tree is dirty; commit your changes first';;
123
# update NEWS to have today's date, plus desired version number and $type
144
# Ensure the current branch name is correct:
145
curr_br=$(git rev-parse --symbolic-full-name HEAD)
146
test "$curr_br" = refs/heads/$branch || die not on branch $branch
148
# Extract package name from Makefile.
149
Makefile=$builddir/Makefile
150
pkg=$(sed -n 's/^PACKAGE = \(.*\)/\1/p' "$Makefile") \
151
|| die "failed to determine package name from $Makefile"
153
# Check that line 3 of NEWS is the stub line about to be replaced.
154
test "$(sed -n 3p NEWS)" = "$noteworthy_stub" \
155
|| die "line 3 of NEWS must be exactly '$noteworthy_stub'"
157
## --------------- ##
159
## --------------- ##
161
# Update NEWS to have today's date, plus desired version number and $type.
124
162
perl -MPOSIX -ni -e 'my $today = strftime "%F", localtime time;' \
125
163
-e 'my ($type, $ver) = qw('"$type $ver"');' \
126
164
-e 'my $pfx = "'"$noteworthy"'";' \
127
165
-e 'print $.==3 ? "$pfx $ver ($today) [$type]\n" : $_' \
128
166
NEWS || die 'failed to update NEWS'
130
# Ensure the current branch name is correct:
131
curr_br=$(git rev-parse --symbolic-full-name HEAD)
132
test "$curr_br" = refs/heads/$branch || die not on branch $branch
134
168
printf "version $ver\n\n* NEWS: Record release date.\n" \
135
169
| git commit -F - -a || die 'git commit failed'
136
170
git tag -s -m "$pkg $ver" v$ver HEAD || die 'git tag failed'