forked from vzaccaria/DynCSS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomplete-deploy
More file actions
executable file
·177 lines (140 loc) · 3.29 KB
/
complete-deploy
File metadata and controls
executable file
·177 lines (140 loc) · 3.29 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#!/usr/bin/env sh
set -e
function build_package {
phase "Building the library"
cult build-clean
cult default
rm -rf lib
mkdir -p lib
phase "Copying the library"
run 'cp dist/js/client.js lib/dyncss.js'
phase "Testing the library"
run "cd assets/js && make"
}
function add_package_to_repo {
run "cd $dstdir"
phase "Adding the library to the repo"
run "git add lib/dyncss.js"
}
usage="
Usage: complete-deploy
description
-i --increment <level>
Specify the level of the current version number to increment.
Valid levels are 'major', 'minor', 'patch', and 'prerelease'.
'patch' is assumed if this option is omitted.
-d --dry-run
Print the commands without evaluating them.
"
# Absolute path:
#
# Usage: abs=`get_abs_path ./deploy/static`
# echo $abs
#
function get_abs_path {
dir=$(cd `dirname $1` >/dev/null; pwd )
echo $dir
}
#
# Get basename:
function get_base_name {
n=$1
n=$(basename "$n")
echo "${n%.*}"
}
#if [ $? -eq 0 ]
#then
# echo "it worked"
#else
# echo "it failed"
#fi
# Source directory
#
srcdir=`dirname $0`
srcdir=`cd $srcdir; pwd`
#
# Temp directory:
#
# dstdir=`mktemp -d -t bashtmp`
#
# or current:
#
dstdir=`pwd`
function directory_does_exist {
if [ ! -d "$1" ]; then
echo 'true'
else
echo 'false'
fi
}
bold=$(tput bold)
reset=$(tput sgr0)
function print_important_message {
printf "${bold}$1${reset}\n"
}
function ask_for_key {
printf "Press [enter] to continue"
read -s # suppress user input
echo
}
# dryrun
dry_run=false
run() {
echo "$1"
if [[ $dry_run == false ]] ; then
eval "$1"
fi
}
increment=patch
branch=master
while (($# > 0)) ; do
option="$1"
shift
case "$option" in
-h|--help)
echo "$usage"
exit
;;
-i|--increment) increment="$1" ; shift ;;
-d|--dry-run) dry_run=true ;;
*)
echo "Unrecognized option $option" >&2
exit 1
esac
done
function phase {
printf "\n"
printf "\n"
printf "# \n"
printf "# $1 \n"
}
print_important_message "This will commit both the site and a new version of the package"
print_important_message "Make sure you've committed all changes to master"
ask_for_key
build_package
add_package_to_repo
phase "Updating bower package"
name=$(node -p "require('$dstdir/bower.json').name" 2>/dev/null) ||
(echo "Cannot read package name" >&2 ; exit 1)
print_important_message "Current package is: $name"
version=$(node -p "require('$dstdir/bower.json').version" 2>/dev/null) ||
(echo "Cannot read package version " >&2 ; exit 1)
print_important_message "Current package version is: $version"
next_version=$("semver" -i "$increment" "$version")
message_template='Version X.Y.Z'
tag_template=vX.Y.Z
message="${message_template//X.Y.Z/$next_version}"
tag="${tag_template//X.Y.Z/$next_version}"
run "node -e '$(echo "
var o = require('$dstdir/bower.json');
o.version = '$next_version';
var s = JSON.stringify(o, null, 2) + '\n';
require('fs').writeFileSync('$dstdir/bower.json', s);
" | tr "'" '"' | tr -d "\n" | sed "s/^[ ]*//" | tr -s " ")'"
phase "Committing bower package"
run "git add bower.json"
run "git commit --message '$message'"
run "git tag --annotate '$tag' --message '$message'"
run "git push origin 'refs/heads/$branch' 'refs/tags/$tag'"
phase "Updating the website"
run 'cult ftp'