forked from kohana/kohana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease-tag
executable file
·72 lines (55 loc) · 2.01 KB
/
release-tag
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
# This script deploys kohana to zip / tar / gzip format & removes development extras
# It expects a valid git tag as the first parameter
DEPLOY_DIR="kohana_release"
TESTING_FILES="application/test_bootstrap.php phpunit.xml code_coverage.xml phpunitcc TESTING.md release-tag"
KOHANA_REPO="git://github.com/kohana/kohana"
USAGE="\nUsage: $0 {git-tag}
\nWhere {git-tag} is a valid tag in the git repository"
# A tag must be provided as the first argument
if [ -z $1 ]; then
echo "$0 - A small script to prepare a kohana tag for relase."
echo "If unit tests complete it removes testing files and archives the codebase"
echo -e $USAGE
exit 1
fi
# Just setting this lest we need to refactor later on
DEPLOY_TAG=$1
# Bit of a hacky way to find if a tag exists
git tag -l $DEPLOY_TAG | grep -E ".+" &> /dev/null
# Check that the exit code of grep was 0 (i.e. it matched something 1+ times)
if [ $? -ne 0 ]; then
echo "Could not find specified tag in git repo ($DEPLOY_TAG)"
echo -e $USAGE
exit 2
fi
echo "Creating a clean deploy environment called '$DEPLOY_DIR'..."
# Create a clean temp area to deploy our stuff
rm -rf $DEPLOY_DIR
mkdir $DEPLOY_DIR
cd $DEPLOY_DIR
echo "Cloning the repo and checking out the tag to deploy..."
# Bring down a fresh copy of the kohana repo
git clone $KOHANA_REPO repo
cd repo
# Checkout the tag we want to deploy and fetch all the submodules
git checkout --quiet $DEPLOY_TAG
git submodule update --init
echo "Running tests to ensure release is stable..."
phpunit
# We cannot release something that's not stable
if [ $? -ne 0 ]; then
echo "Some unit tests did not pass, exiting release"
exit 3
fi
echo "Removing testing files..."
# Now we remove all unit testing files
rm -vrf $TESTING_FILES
# Including any tests across all modules
find . -type d -regex ".*/tests$" | xargs rm -vrf
# And now we package the whole thing up in archive form
echo "Packaging repo into zip and tar.gz archives..."
zip -r -q $DEPLOY_TAG.zip *
mv $DEPLOY_TAG.zip ../
tar -czf $DEPLOY_TAG.tar.gz *
mv $DEPLOY_TAG.tar.gz ../