-
Notifications
You must be signed in to change notification settings - Fork 3
/
mkrelease
executable file
·132 lines (113 loc) · 4.56 KB
/
mkrelease
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
130
131
132
#!/bin/sh -x
set -e
script_dir=$(dirname "$(readlink -f "$0")")
# Get settings
. "$script_dir/release_settings"
# Early check for asciidoctor, needed for bcftools
type asciidoctor > /dev/null || ( echo "Please add asciidoctor to your PATH" ; exit 1 )
# directory to do the pull and build
TMPDIR=~/tmp/release/$version
TMPDIR=`readlink -m $TMPDIR`
# clean up TMPDIR
mkdir -p $TMPDIR
cd $TMPDIR
# Ensure we have htslib, even if it's not to be released.
if echo "$packages" | grep -v -q htslib ; then
rm -fr htslib
git clone --recurse-submodules http://github.com/$repname/htslib.git
cd htslib
git checkout --recurse-submodules --track origin/master
cd ..
fi
# build each repository in turn
for repo in $packages; do
echo Building $repo
eval 'repo_branch=${'"${repo}_branch"':-$branch}'
eval 'repo_version=${'"${repo}_version"':-$version}'
rm -fr $repo
git clone --recurse-submodules http://github.com/$repname/$repo.git
cd $repo
git checkout --recurse-submodules --track origin/master
git fetch --recurse-submodules origin "$repo_branch":"$repo_branch"
git merge --no-ff --no-commit "$repo_branch"
if [ -e .gitmodules ] ; then
git submodule update
fi
vernum=$(set +x; printf "%d%03d%02d" $(echo $repo_version | tr . ' '))
date=`date +"%-d %B %Y"`
ndate=`echo "$date" | perl -pe '@s = qw(st nd rd); s/^([23]?)([123]) /$1$2$s[$2-1] /; s/^(\d+) /$1th /'`
if [ -e version.sh ] ; then
sed -i "s/^VERSION=[1-9].*/VERSION=$repo_version/" version.sh
git add version.sh
fi
if grep -q -E "PACKAGE_VERSION *= *[1-9]+\.[1-9]+" Makefile ; then
sed -i "s/PACKAGE_VERSION[ ][ ]*=[ ][ ]*[1-9].*/PACKAGE_VERSION = $repo_version/" Makefile
git add Makefile
fi
if grep -q -E "MACH_O_(COMPATIBILITY|CURRENT)_VERSION *= *[1-9]+\.[1-9]+" Makefile ; then
version_part=$(set +x; printf "%d.%d%.0s" $(echo $repo_version | tr . ' '))
sed -E -i "s/MACH_O_(COMPATIBILITY|CURRENT)_VERSION[ ]+=[ ]+3\.[1-9].*/MACH_O_\1_VERSION = 3.$version_part/" Makefile
git add Makefile
fi
if [ -e htslib/hts.h ] && grep -q "define *HTS_VERSION" Makefile ; then
sed -i "/define *HTS_VERSION/s/VERSION .*/VERSION $vernum/" htslib/hts.h
git add htslib/hts.h
fi
if [ "$repo" = htslib ] ; then
# Update htslib.map if necessary, which means we have to build
# the library. We override PACKAGE_VERSION because version.sh
# will still think it's the old one because we haven't tagged yet.
make libhts.so PACKAGE_VERSION="$repo_version"
make htslib.map PACKAGE_VERSION="$repo_version"
git add htslib.map
git clean -f -x .
fi
case $repo in
htslib) manpages="annot-tsv.1 bgzip.1 htsfile.1 htslib-s3-plugin.7 tabix.1" ;;
samtools) manpages=doc/samtools*.1" misc/wgsim.1" ;;
*) manpages=none
esac
if [ "$manpages" != none ] ; then
for mp in $manpages ; do
mp_file=${mp##*/}
name=${mp_file%.[0-9]}
section=${mp_file##*.}
if [ -e "$mp" ] ; then
sed -i "s/^.TH.*/.TH $name $section \"$date\" \"$repo-$repo_version\" \"Bioinformatics tools\"/" "$mp"
git add "$mp"
fi
done
fi
if [ -e README ]; then
sed -i "s/samtools-[0-9].*/samtools-$repo_version # Within the unpacked release directory/" README
sed -i "s/htslib-[0-9].*/htslib-${htslib_version:-$version}/" README
git add README
fi
NEWS=NEWS
if [ -e NEWS.md ]; then
NEWS=NEWS.md
fi
if [ -e "$NEWS" ]; then
qvers=`echo "$repo_version" | sed 's/\./\\./'`
if grep -q -E -i "release $qvers( |$)" "$NEWS" ; then
perl -i -nle 'if ($. < 10 && /release a\.b/i) { $skip = 1; } elsif ($skip && /release \d/i) { $skip = 0; } if (!$skip && /release '"$qvers"'$/i) { $_ .= " ('"$ndate"')" } print unless ($skip);' "$NEWS"
else
perl -i -ple 'if ($. < 10) { if (s/elease a\.b/elease '"$repo_version ($ndate)"'/) { $l = length; print; $_ = <>; if (/^([-~=])/) { $_ = $1 x $l; } } }' "$NEWS"
fi
git add "$NEWS"
fi
if [ -e bam.h ]; then
sed -i "s/BAM_VERSION.*/BAM_VERSION \"$repo_version\"/" bam.h
git add bam.h
fi
if [ -e doc/bcftools.1 ]; then
echo make DOC_VERSION=\"$repo_version\" DOC_DATE=`date +"%Y-%m-%d"` docs
make DOC_VERSION=\"$repo_version\" DOC_DATE=`date +"%Y-%m-%d"` docs
git add doc/bcftools.1 doc/bcftools.html
fi
git commit --no-verify -m "Release $repo_version"
cd ..
"${script_dir}/news2notes.pl" -format tag "$repo/$NEWS" > "${repo}_notes_tag.txt"
"${script_dir}/news2notes.pl" -format sf "$repo/$NEWS" > "${repo}_notes_sf.txt"
"${script_dir}/news2notes.pl" -format github "$repo/$NEWS" > "${repo}_notes_github.txt"
done