1#!/bin/bash
2
3PWD=`pwd`
4WIKIDIR=../selinux.wiki
5
6if [ \! -d $WIKIDIR ]; then
7    git clone git@github.com:SELinuxProject/selinux.wiki.git $WIKIDIR
8fi
9
10RELEASE_TAG=$(date '+%Y%m%d')
11DEST=releases/$RELEASE_TAG
12DIRS="libsepol libselinux libsemanage checkpolicy secilc policycoreutils mcstrans restorecond semodule-utils"
13DIRS_NEED_PREFIX="dbus gui python sandbox"
14
15git tag -a $RELEASE_TAG -m "Release $RELEASE_TAG"
16
17rm -rf $DEST
18mkdir -p $DEST
19
20for i in $DIRS; do
21	cd $i
22	VERS=`cat VERSION`
23	ARCHIVE=$i-$VERS.tar.gz
24	git tag $i-$VERS > /dev/null 2>&1
25	git archive --format=tar --prefix=$i-$VERS/ $i-$VERS | gzip > ../$DEST/$ARCHIVE
26	cd ..
27done
28
29for i in $DIRS_NEED_PREFIX; do
30	cd $i
31	VERS=`cat VERSION`
32	ARCHIVE=selinux-$i-$VERS.tar.gz
33	git tag selinux-$i-$VERS > /dev/null 2>&1
34	git archive --format=tar --prefix=selinux-$i-$VERS/ selinux-$i-$VERS | gzip > ../$DEST/$ARCHIVE
35	cd ..
36done
37
38cd $DEST
39
40git add .
41
42echo "Add the following to the $WIKIDIR/Releases.md wiki page:"
43
44echo ""
45
46echo "## Release $(date '+%Y-%m-%d')"
47
48echo ""
49
50echo "[Release Notes](https://github.com/SELinuxProject/selinux/releases/download/$RELEASE_TAG/RELEASE-$RELEASE_TAG.txt)"
51echo ""
52echo "[full log](https://github.com/SELinuxProject/selinux/releases/download/$RELEASE_TAG/log-$RELEASE_TAG.txt)"
53echo ""
54echo "[short log](https://github.com/SELinuxProject/selinux/releases/download/$RELEASE_TAG/shortlog-$RELEASE_TAG.txt)"
55echo ""
56
57for i in *.tar.gz; do
58
59	echo -n "[$i](https://github.com/SELinuxProject/selinux/releases/download/$RELEASE_TAG/$i) "
60	sha256sum $i | cut -d " " -f 1
61	echo ""
62done
63
64echo "And then run:"
65echo "  cd $WIKIDIR"
66echo "  git commit  -m \"Release $RELEASE_TAG\" -a -s"
67echo "  git push"
68
69echo ""
70echo "Push the release and its tags to git via:"
71echo "  git push"
72echo "  git push --tags"
73
74echo ""
75echo "Create a new release from the latest tag on https://github.com/SELinuxProject/selinux/tags"
76
77echo ""
78echo "Add files from releases/$RELEASE_TAG as assets to the new github release"
79