add missing release notes
[samba-web.git] / announce_samba_release.sh
1 #!/bin/sh
2 #
3
4 SAVE_LC_ALL="${LC_ALL}"
5 SAVE_LANG="${LANG}"
6 SAVE_LANGUAGE="${LANGUAGE}"
7
8 LC_ALL=C
9 export LC_ALL
10 LANG=C
11 export LANG
12 LANGUAGE=C
13 export LANGUAGE
14
15 set -u
16 set -e
17 umask 0022
18
19 test -d ".git" || {
20         echo "Run this script from the top-level directory in the"
21         echo "repository"
22         exit 1
23 }
24
25 usage() {
26         echo "usage: $0 <NAME> <PATCHFILE>"
27         echo "$@"
28 }
29
30 NAME=${1-}
31 test -n "${NAME}" || {
32         usage name
33         exit 1
34 }
35 PATCHFILE=${2-}
36 test -n "${PATCHFILE}" || {
37         usage patchfile
38         exit 1
39 }
40
41 test -f "${PATCHFILE}" || {
42         usage file
43         exit 1
44 }
45
46 grep -q "<a name=\"${NAME}\"" "${PATCHFILE}" || {
47         echo "NAME[${NAME}] does not match content of PATCHFILE[${PATCHFILE}]"
48         exit 1
49 }
50
51 grep -q "<a name=\"${NAME}\"" posted_news/*.body.html && {
52         echo "NAME[${NAME}] is not unique, choose another name"
53         grep "<a name=\"${NAME}\"" posted_news/*.body.html
54         exit 1
55 }
56
57 nd=$(git diff -p --stat HEAD | wc -l)
58 test x"${nd}" = x"0" || {
59         echo "You have uncommited changes your working tree"
60         git status
61         exit 1
62 }
63
64 trap_handler() {
65         echo ""
66         echo "ERROR: cleaning up"
67         echo ""
68
69         for f in ${CLEANUP_FILES}; do
70                 echo "Removing file[${f}]"
71                 test -f "${f}" && {
72                         rm "${f}" || {
73                                 echo "failed to remove ${f}"
74                         }
75                 }
76         done
77
78         test -n "${CLEANUP_RESET_COMMIT}" && {
79                 echo "Reverting to commit[${CLEANUP_RESET_COMMIT}]"
80                 git reset "${CLEANUP_RESET_COMMIT}"
81         }
82 }
83
84 CLEANUP_FILES=""
85 trap trap_handler INT QUIT TERM EXIT
86
87 utcdate=$(date --utc +"%d %B %Y")
88 utctime=$(date --utc +"%Y%m%d-%H%M%S")
89
90 CLEANUP_FILES=""
91 CLEANUP_RESET_COMMIT="HEAD"
92 cat "${PATCHFILE}" | \
93         sed -e "s!@UTCTIME@!${utctime}!g" -e "s!@UTCDATE@!${utcdate}!g" | \
94         git am --ignore-whitespace
95 CLEANUP_RESET_COMMIT="HEAD^"
96
97 echo ""
98 echo "Once you have pushed the commit a cronjob updates"
99 echo "the webserver content every 5-10 mins."
100 echo ""
101 echo "Please verify the commit carefully before pushing:"
102 echo ""
103 echo "  git show -p --stat HEAD"
104 echo "  git push ..."
105 echo ""
106
107 trap - INT QUIT TERM EXIT
108 exit 0