VirtualBox

source: kBuild/vendor/grep/2.12/build-aux/do-release-commit-and-tag

Last change on this file was 2595, checked in by bird, 12 years ago

gnu grep version 2.12 (grep-2.12.tar.xz, md5sum=8d2f0346d08b13c18afb81f0e8aa1e2f)

File size: 4.5 KB
Line 
1#!/bin/sh
2# In a git/autoconf/automake-enabled project with a NEWS file and a version-
3# controlled .prev-version file, automate the procedure by which we record
4# the date, release-type and version string in the NEWS file. That commit
5# will serve to identify the release, so apply a signed tag to it as well.
6VERSION=2011-05-04.11 # UTC
7
8# Note: this is a bash script (could be zsh or dash)
9
10# Copyright (C) 2009-2012 Free Software Foundation, Inc.
11
12# This program is free software: you can redistribute it and/or modify
13# it under the terms of the GNU General Public License as published by
14# the Free Software Foundation, either version 3 of the License, or
15# (at your option) any later version.
16
17# This program is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20# GNU General Public License for more details.
21
22# You should have received a copy of the GNU General Public License
23# along with this program. If not, see <http://www.gnu.org/licenses/>.
24
25# Written by Jim Meyering
26
27ME=`basename "$0"`
28warn() { printf '%s: %s\n' "$ME" "$*" >&2; }
29die() { warn "$*"; exit 1; }
30
31help_version()
32{
33 case $1 in
34 --help) cat <<EOF
35Usage: $ME [OPTION...] VERSION RELEASE_TYPE
36
37Run this script to perform the final pre-release NEWS update
38in which the date, release-type and version string are recorded.
39Commit that result with a log entry marking the release, and apply
40a signed tag. Run it from your project's top-level directory.
41
42Requirements:
43- you use git for version-control
44- a NEWS file, with line 3 identical to this:
45* Noteworthy changes in release ?.? (????-??-??) [?]
46- a version-controlled .prev-version file
47
48Options:
49 --branch BRANCH set release branch (default: master)
50 --help print this help, then exit
51 --version print version number, then exit
52
53EXAMPLE:
54To update NEWS and tag the beta 8.1 release of coreutils, I would run this:
55
56 $ME 8.1 beta
57
58Report bugs and patches to <bug-gnulib@gnu.org>.
59EOF
60 exit ;;
61
62 --version)
63 year=`echo "$VERSION" | sed 's/[^0-9].*//'`
64 cat <<EOF
65$ME $VERSION
66Copyright (C) $year Free Software Foundation, Inc,
67License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
68This is free software: you are free to change and redistribute it.
69There is NO WARRANTY, to the extent permitted by law.
70EOF
71 exit ;;
72
73 *) die "unrecognized option: $1";;
74 esac
75}
76
77branch=master
78case $1 in
79 --branch) shift; branch=$1; shift ;;
80esac
81
82case $# in
83 1) help_version $1; exit 0;;
84 2) ;;
85 *) warn "Usage: $ME [OPTION...] VERSION TYPE"; exit 1;;
86esac
87
88ver=$1
89type=$2
90
91# Verify that $ver looks like a version number, and...
92echo "$ver"|grep -E '^[0-9][0-9.]*[0-9]$' > /dev/null \
93 || die "invalid version: $ver"
94prev_ver=$(cat .prev-version) \
95 || die 'failed to determine previous version number from .prev-version'
96
97# Verify that $ver is sensible (> .prev-version).
98case $(printf "$prev_ver\n$ver\n"|sort -V -u|tr '\n' ':') in
99 "$prev_ver:$ver:") ;;
100 *) die "invalid version: $ver";;
101esac
102
103case $type in
104 alpha|beta|stable) ;;
105 *) die "invalid release type: $type";;
106esac
107
108# Extract package name from Makefile.
109pkg=$(sed -n 's/^PACKAGE = \(.*\)/\1/p' Makefile) \
110 || die 'failed to determine package name from Makefile'
111
112# simple check: no question marks on line 3 of NEWS
113noteworthy='* Noteworthy changes in release'
114test "$(sed -n 3p NEWS)" = "$noteworthy ?.? (????-??-??) [?]" \
115 || die 'line 3 of NEWS looks fishy!'
116
117# No dirt allowed.
118case $(git diff-index --name-only HEAD) in
119 '') ;;
120 *) die 'this tree is dirty; commit your changes first';;
121esac
122
123# update NEWS to have today's date, plus desired version number and $type
124perl -MPOSIX -ni -e 'my $today = strftime "%F", localtime time;' \
125 -e 'my ($type, $ver) = qw('"$type $ver"');' \
126 -e 'my $pfx = "'"$noteworthy"'";' \
127 -e 'print $.==3 ? "$pfx $ver ($today) [$type]\n" : $_' \
128 NEWS || die 'failed to update NEWS'
129
130# Ensure the current branch name is correct:
131curr_br=$(git rev-parse --symbolic-full-name HEAD)
132test "$curr_br" = refs/heads/$branch || die not on branch $branch
133
134printf "version $ver\n\n* NEWS: Record release date.\n" \
135 | git commit -F - -a || die 'git commit failed'
136git tag -s -m "$pkg $ver" v$ver HEAD || die 'git tag failed'
137
138# Local variables:
139# indent-tabs-mode: nil
140# eval: (add-hook 'write-file-hooks 'time-stamp)
141# time-stamp-start: "VERSION="
142# time-stamp-format: "%:y-%02m-%02d.%02H"
143# time-stamp-time-zone: "UTC"
144# time-stamp-end: " # UTC"
145# End:
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette