@@ -3,64 +3,13 @@ set -euo pipefail
3
3
4
4
source ./source.sh
5
5
6
- # doc> _docIndent_
7
- # doc>> Indents and filters the documentation depeding on the number of
8
- # doc>> '>' characters used.
9
- function docIndent() {
10
- DOCTYPE=${1-' [a-zA-Z0-9]*' }
11
-
12
- script=$( cat << 'EOD '
13
- my $dt = $ENV{DOCTYPE};
14
- while(<>) {
15
- if($_ =~ /^#$dt(>+)/) {
16
- $_ =~ s/^#$dt//;
17
- $_ =~ s/^( *)>\s*/$1 / while($_ =~ /^ *>\s*/);
18
- print $_;
19
- }
20
- }
21
- EOD
22
- )
23
-
24
- DOCTYPE=" $DOCTYPE " perl -e " $script "
25
- }
26
-
27
- # doc> _docPretty_
28
- # doc>> Use simple markup to underline headlines.
29
- function docPretty() {
30
- perl -pne ' s/^( *)_(.+)_/\n$1' " $( tput smul) " ' $2' " $( tput rmul) " ' /'
31
- }
32
-
33
- # > _help_
34
- # >> Print an overview of all targets.
35
- function help() {
36
- echo " usage: $0 COMMAND"
37
- echo " "
38
- echo " Commands:"
39
- docIndent " " < " $0 " | docPretty
40
- }
41
-
42
- # > _dev_
43
- # >> Start the development node server
44
6
function dev() {
45
7
if [ ! -d node_modules ] ; then
46
- npm install
47
- fi
48
- npm run dev
49
- }
50
-
51
- # > _dev-container_ [COMMAND...]
52
- # >> Start the development container with the given command. If no
53
- # >> command is given, the development server is started instead.
54
- function dev_container() {
55
- local ARGS=(" $@ " )
56
- if ! (( ${# ARGS[@]} )) ; then
57
- ARGS=(" ./start.sh" " dev" )
8
+ _npm install
58
9
fi
59
- docker-compose -f docker-compose.dev.yml run --service-ports --rm node ${ARGS[*]}
10
+ docker-compose -f docker-compose.dev.yml run --service-ports --rm node npm run dev
60
11
}
61
12
62
- # > _build_
63
- # >> Do a production-ready build
64
13
function build() {
65
14
if [ " $( id -u) " == " 0" ] ; then
66
15
echo ' warning: trying to build as root user, falling back to user 1000'
@@ -75,20 +24,66 @@ function build() {
75
24
}
76
25
77
26
case " ${1-} " in
78
- " help" )
79
- help ;;
80
27
" dev" )
81
28
dev;;
82
- " dev-container" )
83
- dev_container " ${@: 2} " ;;
84
29
" build" )
85
30
build;;
31
+ " release" )
32
+ if [[ -f .npmrc ]] ; then
33
+ echo " no .npmrc file exists, please create it (//registry.npmjs.org/:_authToken=<token>)"
34
+ exit 1
35
+ fi
36
+
37
+ if ! _npm whoami ; then
38
+ echo " you need to be logged into the npm registry before creating a release"
39
+ exit 1
40
+ fi
41
+
42
+ VERSION=$( git-conventional-commits version)
43
+ echo " -- creating release for version ${VERSION} "
44
+
45
+ echo " -- patching package{,-lock}.json"
46
+ jq " .version=\" ${VERSION} \" " package.json > package.json.tmp && mv package.json.tmp package.json
47
+ _npm i > /dev/null
48
+
49
+ echo " -- building release artifacts"
50
+ build
51
+
52
+ echo " -- creating release commit"
53
+ git commit -am" build(release): bump project version to ${VERSION} "
54
+
55
+ echo " -- creating changelog"
56
+ git-conventional-commits changelog --release " $VERSION " --file CHANGELOG.md
57
+
58
+ echo " -- creating commit for changelog"
59
+ git commit -am" doc(release): create ${VERSION} change log entry"
60
+
61
+ echo " -- tagging version"
62
+ git tag -a -m" build(release): ${VERSION} " " v${VERSION} "
63
+
64
+ echo " -- tagging docker image"
65
+ docker tag " ${DOCKER_IMAGE_NAME} :latest" " ${DOCKER_IMAGE_NAME} :${VERSION} "
66
+
67
+ read -r -p " -- git push? [Y/n]" response
68
+ response=${response,,} # tolower
69
+ if [[ $response =~ ^(yes| y| ) ]] || [[ -z $response ]]; then
70
+ git push --atomic origin master " v${VERSION} "
71
+ fi
72
+
73
+ read -r -p " -- npm publish? [Y/n]" response
74
+ response=${response,,} # tolower
75
+ if [[ $response =~ ^(yes| y| ) ]] || [[ -z $response ]]; then
76
+ _npm publish
77
+ fi
78
+
79
+ echo " -- RELEASE DONE"
80
+ ;;
81
+
86
82
* )
87
83
if [ -z ${1+x} ]; then
88
84
echo " no command given"
89
85
else
90
86
echo " invalid command '${1-} '"
91
87
fi
92
- help
93
88
exit 1;;
94
89
esac
0 commit comments