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
10DEST=$WIKIDIR/files/releases/$(date '+%Y%m%d')
11DIRS="libsepol libselinux libsemanage checkpolicy secilc policycoreutils mcstrans restorecond semodule-utils"
12DIRS_NEED_PREFIX="dbus gui python sandbox"
13
14git tag -a $(date '+%Y%m%d') -m "Release $(date '+%Y%m%d')"
15
16rm -rf $DEST
17mkdir -p $DEST
18
19for i in $DIRS; do
20	cd $i
21	VERS=`cat VERSION`
22	ARCHIVE=$i-$VERS.tar.gz
23	git tag $i-$VERS > /dev/null 2>&1
24	git archive --format=tar --prefix=$i-$VERS/ $i-$VERS | gzip > ../$DEST/$ARCHIVE
25	cd ..
26done
27
28for i in $DIRS_NEED_PREFIX; do
29	cd $i
30	VERS=`cat VERSION`
31	ARCHIVE=selinux-$i-$VERS.tar.gz
32	git tag selinux-$i-$VERS > /dev/null 2>&1
33	git archive --format=tar --prefix=selinux-$i-$VERS/ selinux-$i-$VERS | gzip > ../$DEST/$ARCHIVE
34	cd ..
35done
36
37cd $DEST
38
39git add .
40
41echo "Add the following to the $WIKIDIR/Releases.md wiki page:"
42
43echo ""
44
45echo "## Release $(date '+%Y-%m-%d')"
46
47for i in *.tar.gz; do
48
49	echo -n "[$i](https://raw.githubusercontent.com/wiki/SELinuxProject/selinux/files/releases/$(date '+%Y%m%d')/$i) "
50	sha256sum $i | cut -d " " -f 1
51	echo ""
52done
53
54echo "And then run:"
55echo "  cd $WIKIDIR"
56echo "  git commit  -m \"Release $(date '+%Y%m%d')\" -a -s"
57echo "  git push"
58
59echo ""
60echo "Push the release and its tags to git via:"
61echo "  git push"
62echo "  git push --tags"
63