/
.travis.yml
67 lines (57 loc) · 1.8 KB
/
.travis.yml
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
language: node_js
node_js: 18
cache: false
dist: focal
jobs:
include:
- stage: install, check code style and coverage
if: tag IS blank
services:
- mongodb
addons:
hosts:
- localhost
before_script:
- npm install -g grunt-cli
- sleep 10
script:
- grunt
- if [ "$TRAVIS_BRANCH" != "master" ]; then grunt test; fi
- if [ "$TRAVIS_BRANCH" = "master" ]; then grunt coverage; fi
- stage: Publish to npm
if: branch =~ /(release)/
script:
- echo "PUBLISH npm"
deploy:
skip_cleanup: true
provider: npm
email: $NPM_EMAIL
api_key: $NPM_TOKEN
on:
all_branches: true
condition: $TRAVIS_BRANCH =~ ^(release)*
- stage: Publish to docker registry
if: branch =~ /(release)/
script:
- echo "PUBLISH docker"
- export PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -Fn '{ print $2 }' | sed 's/[n:",]//g' | tr -d '[[:space:]]')
- export MAJOR_VERSION=$(echo ${PACKAGE_VERSION} | awk -F. '{ print $1 }')
- echo Package version ${PACKAGE_VERSION}
- echo Major version ${MAJOR_VERSION}
- git config --local user.name ${GIT_USER}
- git config --local user.email ${GIT_EMAIL}
- git tag ${PACKAGE_VERSION}
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- docker build -t soajsorg/gateway .
- docker images
- docker tag soajsorg/gateway:latest soajsorg/gateway:${PACKAGE_VERSION}
- docker tag soajsorg/gateway:latest soajsorg/gateway:${MAJOR_VERSION}.x
- docker push soajsorg/gateway
- docker push soajsorg/gateway:${PACKAGE_VERSION}
- docker push soajsorg/gateway:${MAJOR_VERSION}.x
deploy:
on:
all_branches: true
provider: releases
api_key: ${GIT_TOKEN}
skip_cleanup: true