forked from hyperledger-archives/education-cryptomoji
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish
executable file
·62 lines (53 loc) · 1.59 KB
/
publish
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
#! /bin/bash
# Problemifies the code, then creates new commits and pushes them to the
# `master` and `solution` branches.
#
# Requires `git` and `node`
# Check for uncommitted changes
if [ -n "$( git diff-index --name-only HEAD -- )" ]
then
echo "The working directory must be clean to publish"
echo "Stash or commit your changes"
exit 1
fi
# Save current environment
CURR_DIR="$( pwd )"
ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/../"
CURR_BRANCH="$( git rev-parse --abbrev-ref HEAD )"
# Pull new staging code
# when testing, use `git checkout origin/staging`
git checkout upstream/staging
git branch -f staging
git checkout staging
HEAD="$( git rev-parse HEAD )"
# Problemify code
cd $ROOT_DIR
bin/problemify -p code/
rsync -rv --exclude=.git/ --exclude=node_modules/ ./ tmp/
git checkout -f upstream/master
git branch -f master
git checkout master
rsync -rv --exclude=.git/ --exclude=node_modules/ tmp/ ./
rm -rf tmp/
# Push to master
git add .
git commit -s -m "Problemified code generated from: $HEAD"
# when testing, use `git push -f origin master`
git push upstream master
# Solutionify code
git checkout staging
bin/problemify -s code/
rsync -rv --exclude=.git/ --exclude=node_modules/ ./ tmp/
git checkout -f upstream/solution
git branch -f solution
git checkout solution
rsync -rv --exclude=.git/ --exclude=node_modules/ tmp/ ./
rm -rf tmp/
# Push to solution
git add .
git commit -s -m "Solutionified code generated from: $HEAD"
# when testing, use `git push -f origin solution`
git push upstream solution
# Reset environment
cd $CURR_DIR
git checkout $CURR_BRANCH