-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·56 lines (47 loc) · 1.11 KB
/
deploy.sh
File metadata and controls
executable file
·56 lines (47 loc) · 1.11 KB
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
#!/bin/bash
set -eu
function current_version() {
VTAGS=$(/usr/bin/env git tag -l "v*" --sort="-v:refname")
for VTAG in $VTAGS; do
if [[ $VTAG =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo $VTAG
return 0
fi
done
echo "Could not detect current version"
exit 1
}
pushd $(cd $(dirname $0);pwd)
CURRENT_BRANCH=$(git branch --show-current)
if [ $CURRENT_BRANCH != "master" ]; then
echo "Not on master branch"
exit 1
fi
pushd deploy
composer install
popd
if [ $# -ne 1 ]; then
echo "USAGE: $0 {vA.B.C|minor|patch}"
exit 1
fi
TAG=""
if [ $1 = "current" ]; then
current_version
exit 0
elif [ $1 = "minor" -o $1 = "patch" ]; then
PREV=$(current_version)
TAG=v$(npx semver -i $1 $PREV)
elif [[ $1 =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
TAG=$1
fi
if [[ $TAG =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
git tag -s $TAG -m $TAG
else
echo "Invalid version tag $1. Should be like v1.2.3, 'minor' or 'patch'"
exit 1
fi
git push origin dev master $TAG
pushd deploy
./vendor/bin/dep deploy --tag=$TAG
popd
popd