WinGit: Do not create a release tag if it already exists
[msysgit/kirr.git] / share / WinGit / release.sh
blob19d33c0ae7702ea8cbcdb1d97111e59f787a2a8a
1 #!/bin/bash
3 force=
4 do_compile=t
5 while test $# -gt 0
6 do
7 case "$1" in
8 -f|--force)
9 force=t
10 shift
12 -n|--no-compile)
13 do_compile=
14 shift
17 break
18 esac
19 done
21 test -z "$1" && {
22 echo "Usage: $0 [-f] [-n] <version>" >&2
23 exit 1
26 version=$1
28 # change directory to msysGit root
29 SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)"
30 MSYSGITROOT="$(cd $SCRIPTDIR/../../ && pwd | sed 's/\/$//')/."
31 cd $MSYSGITROOT || {
32 echo "Could not change directory to msysGit root" >&2
33 exit 1
36 test -z "$force" && {
37 die () {
38 echo "$*" >&2
39 echo "If that is okay, please call '$0 -f $version'" >&2
40 exit 1
43 (cd git &&
44 git update-index --refresh &&
45 git diff-files --quiet &&
46 git diff-index --cached HEAD --) ||
47 die "Git submodule has dirty files"
48 (git update-index --refresh &&
49 git diff-files --quiet &&
50 git diff-index --cached HEAD --) ||
51 die "msysGit super project not up-to-date"
54 create_msysgit_tag () {
55 if tag=$(git describe --exact-match --match "*.msysgit.*" HEAD 2> /dev/null)
56 then
57 echo "Using existing tag $tag"
58 else
59 i=0 &&
60 tag=$(git describe HEAD | cut -d- -f1) &&
61 tag=${tag%.msysgit.*} &&
62 while ! git tag -a -m "Git for Windows $1" $tag.msysgit.$i 2> /dev/null
64 i=$(($i+1))
65 done &&
66 echo "Created tag $tag.msysgit.$i"
70 # compile everything needed for standard setup
71 test "$do_compile" && {
72 wordpad share/WinGit/ReleaseNotes.rtf && {
73 ( # create a commit if ReleaseNotes changed
74 if test ! -z "$(git diff share/WinGit/ReleaseNotes.rtf)"
75 then
76 git add share/WinGit/ReleaseNotes.rtf &&
77 git commit -m "Git for Windows $version"
78 fi) &&
79 (cd git &&
80 create_msysgit_tag $version &&
81 make install) &&
82 /src/mingw-w64/release-easy.sh &&
83 /src/mingw-w64/release-zlib.sh &&
84 (cd src/git-cheetah/explorer/ &&
85 make objects-clean && make &&
86 make objects-clean && make W64=1)
87 } || exit 1
90 test -z "$force" && {
91 die () {
92 echo "$*" >&2
93 echo "If that is okay, please call '$0 -f $version'" >&2
94 exit 1
97 (cd git &&
98 git update-index --refresh &&
99 git diff-files --quiet &&
100 git diff-index --cached HEAD --) ||
101 die "Git submodule has dirty files"
102 (cd git &&
103 test git.exe = $((printf 'git.exe\0'; git ls-files -z) | xargs --null ls -t 2>/dev/null| head -1)) ||
104 die "Git's git.exe is not up-to-date (run 'cd /git && make' to fix)"
105 for f in bin/git* libexec/git-core/git*
107 case "$f" in
108 *.manifest)
109 continue
111 */gitk)
112 basename=gitk-git/gitk
114 */git-citool|*/git-gui)
115 basename=git-gui/git-gui
117 */git-gui--askpass|*/git-gui--askyesno|*/git-gui.tcl)
118 basename=git-gui/$(basename "$f")
121 basename=$(basename "$f")
123 esac
124 cmp "$f" "git/$basename" ||
125 die "Installed Git disagrees with contents of /git/ ($f)"
126 done
127 (git update-index --refresh &&
128 git diff-files --quiet &&
129 git diff-index --cached HEAD --) ||
130 die "msysGit super project not up-to-date"
131 (cd git &&
132 test ! -z "$(git tag --contains HEAD)") ||
133 die "Git's HEAD is untagged"
136 TMPDIR=/tmp/WinGit
137 unset DONT_REMOVE_BUILTINS
139 $MSYSGITROOT/share/WinGit/copy-files.sh $TMPDIR &&
140 sed -e '/share\/msysGit/d' -e "s/msysGit/Git (version $version)/" \
141 < etc/motd > $TMPDIR/etc/motd &&
142 cp share/resources/gpl-2.0.rtf share/resources/git.bmp share/resources/gitsmall.bmp $TMPDIR &&
143 sed -e "s/%APPVERSION%/$version/" \
144 < share/WinGit/install.iss > $TMPDIR/install.iss &&
145 cp share/WinGit/*.inc.iss $TMPDIR &&
146 echo "Launching Inno Setup compiler ..." &&
147 (cd $TMPDIR &&
148 if test -x $MSYSGITROOT/share/InnoSetup/ISCC.exe
149 then
150 $MSYSGITROOT/share/InnoSetup/ISCC.exe install.iss
151 else
152 case $(wine --version) in
153 wine-0*|wine-1.[012]*|wine-1.3.[0-9]|wine-1.3.[0-9]-*|wine-1.3.1[0-4]|wine-1.3.1[0-4]-*)
154 echo "You need at least WINE version 1.3.15" >&2 &&
155 exit 1
156 esac &&
157 wine $MSYSGITROOT/share/InnoSetup/ISCC.exe install.iss
158 fi > /tmp/install.out &&
159 echo $? > /tmp/install.status) &&
160 (test 0 = "$(cat /tmp/install.status)") &&
161 git tag -a -m "Git for Windows $1" Git-$1 &&
162 echo "Installer is available as $(tail -n 1 /tmp/install.out)"