f3c414a052e1befd7916e135068573bd87801f89
[xonotic/xonotic.git] / misc / infrastructure / xonotic-release-build.cron
1 #!/bin/sh
2
3 if [ -z "$RELEASETYPE" ]; then
4         export RELEASETYPE=autobuild
5         #export RELEASETYPE=release
6 fi
7
8 case "$RELEASETYPE" in
9         autobuild)
10                 RELEASETYPEDIR=
11                 RELEASETYPENAME="$RELEASETYPE"
12                 ;;
13         *)
14                 RELEASETYPEDIR="$RELEASETYPE/"
15                 RELEASETYPENAME="$RELEASETYPE-like build"
16                 ;;
17 esac
18
19 # is being run as cronjob, better set PATH
20 export PATH=/home/xonotic-build/ccache:/home/xonotic-build/bin:/usr/local/bin:/usr/bin:/bin:/usr/games
21
22 # TEST: use s2tc, high quality
23 #export dds_tool=s2tc
24
25 # Try crunch.
26 export CACHEDIR=$HOME/.xonotic-cached-converter-crunch
27 export dds_tool=crunch
28
29 # Build locally.
30 export HOSTS_THAT_ARE_MYSELF='xonotic-build-linux64 xonotic-build-win32 xonotic-build-win64 xonotic-build-osx'
31
32 mepwd=$PWD
33 me=$0
34
35 if rm "$me.not-today" 2>/dev/null; then
36         echo "No build today (not-today marker removed)!"
37         exit 0
38 fi
39
40 set -ex
41
42 test -z "$RELEASETYPEDIR" && ssh autobuild-release-uploader@beta.xonotic.org '
43         set -e;
44         s0=`date -d "now - 7 days - 12 hours" +%s`;
45         s00=`date -d "now - 60 days - 12 hours" +%s`;
46         for X in * */*; do
47                 [ -f "$X" ] || continue;
48                 d=${X##*/};
49                 d=${d#Xonotic-};
50                 d=${d#gmqcc-};
51                 d=${d%%[-_.]*};
52                 [ x"$d" != x"latest" ] || continue;
53                 w=`date -d $d +%w`;
54                 s=`date -d $d +%s`;
55                 if [ "$w" -ne 0 -a "$s" -lt "$s0" -o "$s" -lt "$s00" ]; then
56                         rm -f "$X";
57                 fi;
58         done
59 '
60
61 cd ~/xonotic-release-build
62 ./all clean --reclone
63 # ./all checkout maint
64 ./all checkout
65 ./all each git checkout HEAD^0
66 # add all feature branches we want
67
68 # map branches that we include:
69 #   winners in the poll for upcoming CTF maps
70 #   maps near completion
71
72 #for b in \
73 #       origin/divVerent/selfbuildagain \
74 #; do
75 #       b=$b ./all each sh -c 'if git rev-parse $b >/dev/null 2>&1; then git merge $b; fi'
76 #done
77 ./all update -N
78 d0=`date +%Y%m%d`
79 d=$d0
80 i=1
81 while HEAD -C xonotic:g-23 http://beta.xonotic.org/autobuild/"$RELEASETYPEDIR""Xonotic-$d.zip"; do
82         i=$(($i+1))
83         d="$d0"_"$i"
84 done
85 RELEASEDATE=$d ./all release
86 sha512sum Xonotic-$d*.zip > Xonotic-$d.sha512
87 for X in Xonotic-$d*.zip; do
88         ln -snf "$X" "Xonotic-latest${X#Xonotic-$d}"
89 done
90 ln -snf Xonotic-$d.sha512 Xonotic-latest.sha512
91 rsync -vaSHP Xonotic*.zip Xonotic*.sha512 autobuild-release-uploader@beta.xonotic.org:"$RELEASETYPEDIR"
92 if [ -z "$RELEASETYPEDIR" ]; then
93         ssh autobuild-release-uploader@beta.xonotic.org sh ../../update-rsync.sh "$d"
94 fi
95 echo "Finished a new $RELEASETYPENAME at http://beta.xonotic.org/autobuild/$RELEASETYPEDIR" | $IRCSPAM
96 cd