-
Notifications
You must be signed in to change notification settings - Fork 18
/
release.sh
executable file
·130 lines (110 loc) · 3.85 KB
/
release.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/bash -ue
# Interactive script for release
# You should `dnf upgrade` before run it
# Check icedtea repository
if [[ "$(hg branch)" != "default" ]]; then
echo "You must be on the default branch of mercurial SCM to release"
exit 1
fi
if [[ ! "$(hg paths default)" =~ .*icedtea\.classpath\.org/hg/release/.* ]]; then
echo "You must be on the icedtea release repository (/hg/release/*) to release"
exit 1
fi
# Check Author
AUTHOR=$(hg config ui.username)
read -p "Is release author: ${AUTHOR} ? (y/n) > " _check
if [[ ${_check} != "y" && ${_check} != "Y" ]]; then
echo "Modify hg config ui.username"
exit 1
fi
# Check Date
DATE=$(LANG=C date "+%Y-%m-%d")
read -p "Is release date: ${DATE} ? (y/n) > " _check_date
if [[ ${_check_date} != "y" && ${_check_date} != "Y" ]]; then
read -p "Enter release date (YYYY-MM-DD) > " DATE
# simple verification to use `date`
if [[ ! ${DATE} =~ [2-9][0-9][0-9][0-9]\-[0-1][0-9]\-[0-3][0-9] ]]; then
echo "Enter correct date as YYYY-MM-DD"
exit 1
fi
# if wrong format, return error by `date`
DATE=$(LANG=C date --date=${DATE} "+%Y-%m-%d")
fi
# Input new version
# show current version by project.version from pom.xml
CURRENT_VERSION=`sed -n 's#^\s\+<version>\(.\+\)</version>#\1#p' pom.xml`
echo "Current version is ${CURRENT_VERSION}"
read -p "Enter release version > " VERSION
if [[ ! ${VERSION} =~ [0-9]\.[0-9]\.[0-9] ]]; then
echo "Enter correct version as [0-9].[0-9].[0-9]"
exit 1
fi
# analyzer
## pom
### parent has 1 version element
sed -i -e "/^\s\+<version>/s#${CURRENT_VERSION}#${VERSION}#g" pom.xml
### children have some version elements
CHILDREN=($(find ./*/ -name "pom.xml" -type f))
for child in ${CHILDREN[@]}; do
# replace version number between <parent> and </parent>
LINE=$(sed -n "/parent/=" ${child} | tr '\n' ',')
sed -i -e "${LINE:0:$((${#LINE}-1))}s#${CURRENT_VERSION}#${VERSION}#g" ${child}
done
## Dialog
sed -i -e "/Version/s#text=\"Version\s.\+\"#text=\"Version ${VERSION}\"#g" analyzer/fx/src/main/resources/jp/co/ntt/oss/heapstats/aboutDialog.fxml
# configure.ac
sed -i -e "/AC_INIT(\[HeapStats\]/s#[0-9]\.[0-9]\.[0-9]#${VERSION}#g" configure.ac
sed -i -e "/HEAPSTATS_MAJOR_VERSION/s#[0-9]\.[0-9]#${VERSION:0:3}#g" configure.ac
## remake configure
autoconf
# heapstats.spec
SPECFILE=specs/heapstats.spec
sed -i -e "/Version:/s#[0-9]\.[0-9]\.[0-9]#${VERSION}#g" ${SPECFILE}
## Copyright
YEAR=$(LANG=C date "+%Y")
TO_YEAR=`sed -n 's#^Copyright\s(C)\s2011-\(.\+\)\sNippon.\+#\1#p' ${SPECFILE}`
TO_YEAR=${TO_YEAR:0:4}
if [[ ${TO_YEAR} != ${YEAR} ]]; then
sed -i "/^Copyright/s#${TO_YEAR}#${YEAR}#g" ${SPECFILE}
fi
## changelog
LINE=$(($(sed -n "/%changelog/=" ${SPECFILE})+1))
SPECDATE=$(LANG=C date --date=${DATE} "+%a %b %d %Y")
sed -i "${LINE}i\* ${SPECDATE} ${AUTHOR}\n- Bump to ${VERSION}" ${SPECFILE}
# ChangeLog
sed -i "1i${DATE} ${AUTHOR}\n\n\t\* Bump to ${VERSION}\n" ChangeLog
# NEWS
## Add template
sed -i "1iNew in release ${VERSION} (${DATE})\n\n* Fix some bugs\n" NEWS
## ... and edit to add more detailed history
read -p "Press ENTER to edit NEWS ..."
if [ -z ${EDITOR+x} ]; then
vim NEWS
else
${EDITOR} NEWS
fi
# remake Makefile by latest automake
automake
bash configure
# hg tag
read -p "Do you want 'hg tag' automatically? (y/n) > " _check_tag
if [[ ${_check_tag} == "y" || ${_check_tag} == "Y" ]]; then
#TODO: hg status / add
hg tag -m "Bump to ${VERSION}" ${VERSION}
fi
cat << _EOF_
==============================================================
All done. Ready to release.
You should check
* hg status to check non-committed files
* hg tags to check tag for new version
* To check changelogs
* NEWS
* ChangeLog
* spec/heapstats.spec
This script also changes the below files
* pom.xml (<version>)
* analyzer/fx/src/main/resources/jp/co/ntt/oss/heapstats/aboutDialog.fxml (Version: XXX)
* configure.ac
==============================================================
_EOF_