blob: 57e89af66d7f57476fec4d2758dafe5215b05efc [file] [log] [blame]
Keith Packardfba7c372008-01-10 10:40:41 -08001#!/bin/sh
Akira TAGOH5918d5b2014-01-17 13:05:25 +09002# fontconfig/new-version.sh
3#
4# Copyright © 2000 Keith Packard
5#
6# Permission to use, copy, modify, distribute, and sell this software and its
7# documentation for any purpose is hereby granted without fee, provided that
8# the above copyright notice appear in all copies and that both that
9# copyright notice and this permission notice appear in supporting
10# documentation, and that the name of the author(s) not be used in
11# advertising or publicity pertaining to distribution of the software without
12# specific, written prior permission. The authors make no
13# representations about the suitability of this software for any purpose. It
14# is provided "as is" without express or implied warranty.
15#
16# THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18# EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22# PERFORMANCE OF THIS SOFTWARE.
Keith Packardfba7c372008-01-10 10:40:41 -080023
Akira TAGOHd6de5352012-03-09 22:24:18 +090024if [ "x`git status -s -uno`" != "x" ]; then
Keith Packardfba7c372008-01-10 10:40:41 -080025 echo 'Uncommited changes in repository' 1>&2
26 exit 1
27fi
28
29version="$1"
30case "$version" in
312.[0-9.]*)
32 ;;
33*)
34 echo 'Invalid version number:' "$version" 1>&2
35 exit 1
36 ;;
37esac
38
39eval `echo $version |
40 awk -F. '{ printf ("major=%d\nminor=%d\nrevision=%d\n",
41 $1, $2, $3); }'`
42
43# Update the version numbers
44
Akira TAGOHc8424122013-03-29 16:07:30 +090045sed -i configure.ac -e "/^AC_INIT(/s/2\.[0-9.]*/$version/"
Keith Packardfba7c372008-01-10 10:40:41 -080046
Keith Packard51f15362008-01-10 10:56:52 -080047sed -i fontconfig/fontconfig.h \
48 -e "/^#define FC_MAJOR/s/[0-9][0-9]*/$major/" \
49 -e "/^#define FC_MINOR/s/[0-9][0-9]*/$minor/" \
50 -e "/^#define FC_REVISION/s/[0-9][0-9]*/$revision/"
Keith Packardfba7c372008-01-10 10:40:41 -080051
Akira TAGOH4c2497b2020-11-28 11:11:46 +090052sed -i meson.build -e "/version: /s/2\.[0-9.]*/$version/"
53
Keith Packardfba7c372008-01-10 10:40:41 -080054#
55# Compute pretty form of new version number
56#
57version_note=`echo $version | awk -F. '{
58 if ($3 > 90)
59 printf ("%d.%d.%d (%d.%d RC%d)\n",
60 $1, $2, $3, $1, $2 + 1, $3 - 90);
61 else if ($3 == 0)
62 printf ("%d.%d\n", $1, $2);
63 else
64 printf ("%d.%d.%d\n", $1, $2, $3); }'`
65
66#
67# Find previous version in README
68#
69last_note=`grep '^2\.[0-9.]*' README |
70 head -1 |
71 sed 's/ (2\.[0-9]* RC[0-9]*)//'`
72case $last_note in
732.*.*)
74 last=$last_note
75 ;;
762.*)
77 last="$last_note.0"
78 ;;
79*)
80 echo 'cannot find previous changelog' 1>&2
81 exit 1
82esac
83
84#
85# Format the current date for the README header
86#
87date=`date '+%Y-%m-%d'`
88
89#
90# Update the readme file
91#
92if [ $version != $last ]; then
93 #
94 # header
95 #
Keith Packard0b15b5f2008-05-03 20:37:49 -070096 (sed '/^2\.[0-9.]*/,$d' README |
Akira TAGOH98352242013-01-10 17:56:51 +090097 sed -r -e "s/Version.*/Version $version_note/" \
98 -e "s/[0-9]{4}\-[0-9]{2}\-[0-9]{2}$/$date/" | awk '
Keith Packardfba7c372008-01-10 10:40:41 -080099 /^[ \t]/ {
100 gsub ("^[ \t]*", "");
101 gsub ("[ \t]*$", "");
102 space=(70 - length) / 2;
103 for (i = 0; i < space; i++)
104 printf (" ");
105 print
106 next
107 }
108 {
109 print
110 }'
111
112 #
113 # changelog
114 #
115
116 echo $version_note
117 echo
Behdad Esfahbodb9b01b62009-03-12 13:48:07 -0400118 git log --pretty=short $last.. | git shortlog | cat
Keith Packardfba7c372008-01-10 10:40:41 -0800119
120 #
121 # previous changelogs
122 #
123
Keith Packard0b15b5f2008-05-03 20:37:49 -0700124 sed -n '/^2\.[0-9.]*/,$p' README) > README.tmp ||
Keith Packardfba7c372008-01-10 10:40:41 -0800125 (echo "README update failed"; exit 1)
126
Keith Packard51f15362008-01-10 10:56:52 -0800127 mv README.tmp README
Keith Packardfba7c372008-01-10 10:40:41 -0800128fi
129
Behdad Esfahbodb9b01b62009-03-12 13:48:07 -0400130$test git commit -m"Bump version to $version" \
Akira TAGOH2d9ad542012-06-18 18:31:36 +0900131 configure.ac \
Keith Packardfba7c372008-01-10 10:40:41 -0800132 fontconfig/fontconfig.h \
Akira TAGOH4ac33d12020-11-28 11:31:02 +0900133 meson.build \
Keith Packardfba7c372008-01-10 10:40:41 -0800134 README
135
136# tag the tree
Behdad Esfahbod76374f02009-06-24 15:19:13 -0400137$test git tag -s -m "Version $version" $version
Keith Packardfba7c372008-01-10 10:40:41 -0800138
139# Make distributed change log
140
Behdad Esfahbodb9b01b62009-03-12 13:48:07 -0400141git log --stat $last.. > ChangeLog-$version
Keith Packardfba7c372008-01-10 10:40:41 -0800142