-
Notifications
You must be signed in to change notification settings - Fork 3
/
create_branch.sh
executable file
·37 lines (28 loc) · 1.09 KB
/
create_branch.sh
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
#!/usr/bin/env bash
MY_PATH="`dirname \"$0\"`"
cd ${MY_PATH}
#find the generator-angular-fullstack source
#this is usually 2 direcories up as this is a submodule
#but use your own if you want to
FULLSTACK_DIR=${DEFAULT_FULLSTACK_DIR:='..'}
echo "Using ${FULLSTACK_DIR} to create branch"
ver=$(grep version ${FULLSTACK_DIR}/package.json |cut -f2 -d:|sed -e 's/"//g; s/,//; s/ //g')
echo "attempting to checkout ${ver} branch"
git checkout ${ver}
if [ $? != 0 ]; then
echo "attempting to create ${ver} branch from master"
git pull origin master
git checkout -b ${ver} master
if [ $? != 0 ]; then
echo "failed to create branch, exitting"
exit 99
fi
fi
echo "building package.json, typings.json and Dockerfile"
sed -e 's/<%.*%>//; /name/d' ${FULLSTACK_DIR}/templates/app/_package.json > package.json
sed -e 's/<%.*%>//; /name/d' "${FULLSTACK_DIR}/templates/app/typings(ts).json" > typings.json
sed -i .bak "s/LABEL.*/LABEL \"version\"=\"${ver}\"/" Dockerfile
sed -i .bak "s/\"version\".*/\"version\": \"${ver}\",/" package.json
git add .
git commit -m "circleci push to ${ver}"
git push origin ${ver}