-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy path.travis.yml
130 lines (121 loc) · 4.75 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
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
# 2017 March 22
# https://github.com/bevry/base
# Use the latest travis infrastructure
sudo: false
# Complete Node.js Version Matrix
# https://github.com/balupton/awesome-travis#complete-nodejs-version-matrix
language: node_js
node_js:
- "0.8" # end of life
- "0.10" # end of life
- "0.12" # maintenance
- "4" # lts
- "6" # lts
- "7" # stable
matrix:
fast_finish: true
allow_failures:
- node_js: "0.8"
- node_js: "0.10"
cache:
directories:
- $HOME/.npm # npm's cache
install: |
# Ensure NPM is latest
# https://github.com/balupton/awesome-travis#ensure-npm-is-latest
export CURRENT_NPM_VERSION="$(npm --version)" || exit -1
export LATEST_NPM_VERSION="$(npm view npm version)" || exit -1
if test "$CURRENT_NPM_VERSION" != "$LATEST_NPM_VERSION"; then
echo "running an old npm version $CURRENT_NPM_VERSION, upgrading npm to $LATEST_NPM_VERSION..."
npm install npm --global --cache-min=Infinity || exit -1
echo "...npm upgrade complete"
fi
# Ensure dependencies install with a LTS node version
# https://github.com/balupton/awesome-travis#use-lts-node-version-for-preparation
export CURRENT_NODE_VERSION="$(node --version)" || exit -1
export LTS_NODE_VERSIONS="$(nvm ls-remote --lts)" || exit -1
if echo "$LTS_NODE_VERSIONS" | grep "$CURRENT_NODE_VERSION"; then
echo "running on a LTS node version, completing setup..."
npm run our:setup || exit -1
echo "...setup complete with current LTS version"
else
echo "running on a non-LTS node version, completing setup on a LTS node version..."
nvm install --lts || exit -1
export LTS_NODE_INSTALLED_VERSION="$(node --version)" || exit -1
npm run our:setup || exit -1
nvm use "$TRAVIS_NODE_VERSION" || exit -1
echo "...setup complete with LTS"
fi
before_script: |
# Ensure compilation and linting occur on a LTS node version
# https://github.com/balupton/awesome-travis#use-lts-node-version-for-preparation
if test "$LTS_NODE_INSTALLED_VERSION"; then
echo "running on a non-LTS node version, compiling with LTS, skipping linting..."
nvm use "$LTS_NODE_INSTALLED_VERSION" || exit -1
npm run our:compile || exit -1
nvm use "$TRAVIS_NODE_VERSION" || exit -1
echo "...compiled"
else
echo "running on a LTS node version, compiling and linting..."
npm run our:compile && npm run our:verify || exit -1
echo "...compiled and linted"
fi
after_success: |
# Release to Surge
# https://github.com/balupton/awesome-travis#release-to-surge
export CURRENT_NODE_VERSION="$(node --version)" || exit -1
export LTS_NODE_LATEST_VERSION="$(nvm version-remote --lts)" || exit -1
if test "$CURRENT_NODE_VERSION" = "$LTS_NODE_LATEST_VERSION"; then
echo "running on latest LTS node version, performing release to surge..."
echo "preparing release"
npm run our:meta || exit -1
echo "installing surge"
npm install surge || exit -1
echo "performing deploy"
export SURGE_SLUG="$(echo $TRAVIS_REPO_SLUG | sed 's/^\(.*\)\/\(.*\)/\2.\1/')" || exit -1
if test "$TRAVIS_BRANCH"; then
echo "deploying branch..."
surge --project $SURGE_PROJECT --domain "$TRAVIS_BRANCH.$SURGE_SLUG.surge.sh" || exit -1
fi
if test "$TRAVIS_TAG"; then
echo "deploying tag..."
surge --project $SURGE_PROJECT --domain "$TRAVIS_TAG.$SURGE_SLUG.surge.sh" || exit -1
fi
if test "$TRAVIS_COMMIT"; then
echo "deploying commit..."
surge --project $SURGE_PROJECT --domain "$TRAVIS_COMMIT.$SURGE_SLUG.surge.sh" || exit -1
fi
echo "...released to surge"
else
echo "running on non-latest LTS node version, skipping release to surge"
fi
# Release to NPM
# https://github.com/balupton/awesome-travis#release-to-npm
export CURRENT_NODE_VERSION="$(node --version)" || exit -1
export LTS_NODE_LATEST_VERSION="$(nvm version-remote --lts)" || exit -1
if test "$CURRENT_NODE_VERSION" = "$LTS_NODE_LATEST_VERSION"; then
if test "$TRAVIS_TAG"; then
echo "logging in..."
echo -e "$NPM_USERNAME\n$NPM_PASSWORD\n$NPM_EMAIL" | npm login || exit -1
echo "publishing..."
npm publish || exit -1
echo "...released to npm"
else
echo "non-tag, no need for release"
fi
else
echo "running on non-latest LTS node version, skipping release to npm"
fi
# ========================================
# Custom Configuration
# https://github.com/bevry/base#configuration
env:
global:
# Release to NPM
# https://github.com/balupton/awesome-travis#release-to-npm
# Release to Surge
# https://github.com/balupton/awesome-travis#release-to-surge
- SURGE_PROJECT='.' # ths is the path that you want to deploy to surge
# Custom Configuration for this repository
# https://github.com/balupton/awesome-travis#slack
# https://github.com/balupton/awesome-travis#email