GIT: Make automated releases and daily snapshots
If you like to make automated snapshots and releases of the latest tagged version of your git repo, try the following bash script. It also generates a sha1sum and a md5sum file:
#!/bin/bash
DEST_DIR=/var/www/example.com/downloads/myproject
GIT_DIR=/var/cache/git/myproject.git
(
cd $GIT_DIR;
git archive --format=tar HEAD | gzip > ${DEST_DIR}/daily-snapshot.tar.gz
latest_tag=`git-tag | tail -n 1`;
if [ ! -f "${DEST_DIR}/${latest_tag}.tar.gz" ]
then
git archive –format=tar $latest_tag | gzip > ${DEST_DIR}/${latest_tag}.tar.gz
git-log > ${DEST_DIR}/changelog.txt
fi
cd $DEST_DIR;
echo “” > ./md5sums.txt;
ls -a *.tar.gz | xargs md5sum >> ./md5sums.txt;
echo “” > ./sha1sums.txt;
ls -a *.tar.gz | xargs sha1sum >> ./sha1sums.txt;
)