forked from center-key/node-slate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
task-runner.sh.command
executable file
·96 lines (89 loc) · 2.47 KB
/
task-runner.sh.command
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
#!/bin/bash
##############
# node-slate #
##############
# To make this file runnable:
# $ chmod +x *.sh.command
banner="node-slate"
projectHome=$(cd $(dirname $0); pwd)
webPage=build/index.html
setupTools() {
# Check for Node.js installation and download project dependencies
cd $projectHome
echo
echo $banner
echo $(echo $banner | sed s/./=/g)
pwd
test -d .git && git pull --ff-only
echo
echo "Node.js:"
which node || { echo "Need to install Node.js: https://nodejs.org"; exit; }
node --version
npm install --no-fund
npm update
npm outdated
echo
}
releaseInstructions() {
cd $projectHome
repository=$(grep repository package.json | awk -F'"' '{print $4}' | sed s/github://)
package=https://raw.githubusercontent.com/$repository/master/package.json
version=v$(grep '"version"' package.json | awk -F'"' '{print $4}')
pushed=v$(curl --silent $package | grep '"version":' | awk -F'"' '{print $4}')
released=$(git tag | tail -1)
minorVersion=$(echo ${pushed:1} | awk -F"." '{ print $1 "." $2 }')
echo "Local changes:"
git status --short
echo
echo "Recent releases:"
git tag | tail -5
echo
echo "Release progress:"
echo " $version (local) --> $pushed (pushed) --> $released (released)"
echo
test "$version" ">" "$released" && mode="NOT released" || mode="RELEASED"
echo "Current version is: $mode"
echo
nextActionBump() {
echo "When ready to do the next release:"
echo
echo " === Increment version ==="
echo " Edit pacakge.json to bump $version to next version number"
echo " $projectHome/package.json"
}
nextActionCommitTagPub() {
echo "Verify all tests pass and then finalize the release:"
echo
echo " === Commit and push ==="
echo " Check in all changed files with the message:"
echo " Release $version"
echo
echo " === Tag and publish ==="
echo " cd $projectHome"
echo " git tag --annotate --message 'Release' $version"
echo " git remote --verbose"
echo " git push origin --tags"
echo " npm publish"
}
test "$version" ">" "$released" && nextActionCommitTagPub || nextActionBump
echo
}
runTasks() {
cd $projectHome
echo "Tasks:"
npm test
npm run build
echo
}
openBrowser() {
cd $projectHome
echo "Opening:"
echo "$projectHome/$webPage"
echo
sleep 2
open $webPage
}
setupTools
releaseInstructions
runTasks
openBrowser