forked from video-dev/hls.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
travis.sh
executable file
·85 lines (82 loc) · 2.69 KB
/
travis.sh
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
#!/bin/bash
# https://docs.travis-ci.com/user/customizing-the-build/#Implementing-Complex-Build-Steps
set -ev
echo "travis_fold:start:npm_install"
npm install
echo "travis_fold:end:npm_install"
if [ "${TRAVIS_MODE}" = "build" ]; then
echo "travis_fold:start:lint"
npm run lint
echo "travis_fold:end:lint"
echo "travis_fold:start:build"
npm run build
echo "travis_fold:end:build"
# check that hls.js doesn't error if requiring in node
# see https://github.com/video-dev/hls.js/pull/1642
node -e 'require("./" + require("./package.json").main)'
elif [ "${TRAVIS_MODE}" = "unitTests" ]; then
npm run test:unit
elif [ "${TRAVIS_MODE}" = "funcTests" ]; then
npm run build
n=0
maxRetries=1
until [ $n -ge ${maxRetries} ]
do
if [ $n -gt 0 ]; then
echo "Retrying... Attempt: $((n+1))"
delay=$((n*60))
echo "Waiting ${delay} seconds..."
sleep $delay
fi
npm run test:func && break
n=$[$n+1]
done
if [ ${n} = ${maxRetries} ]; then
exit 1
fi
elif [ "${TRAVIS_MODE}" = "release" ] || [ "${TRAVIS_MODE}" = "releaseCanary" ] || [ "${TRAVIS_MODE}" = "netlifyPr" ]; then
# update the version
if [[ $(git rev-parse --is-shallow-repository) = "true" ]]; then
# make sure everything is fetched https://github.com/travis-ci/travis-ci/issues/3412
git fetch --unshallow
fi
node ./scripts/set-package-version.js
npm run lint
npm run build
if [ "${TRAVIS_MODE}" != "netlifyPr" ]; then
npm run test:unit
if [[ $(node ./scripts/check-already-published.js) = "not published" ]]; then
# write the token to config
# see https://docs.npmjs.com/private-modules/ci-server-config
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> .npmrc
if [ "${TRAVIS_MODE}" = "releaseCanary" ]; then
npm publish --tag canary
echo "Published canary."
curl https://purge.jsdelivr.net/npm/hls.js@canary
curl https://purge.jsdelivr.net/npm/hls.js@canary/dist/hls-demo.js
echo "Cleared jsdelivr cache."
elif [ "${TRAVIS_MODE}" = "release" ]; then
tag=$(node ./scripts/get-version-tag.js)
if [ "${tag}" = "canary" ]; then
# canary is blacklisted because this is handled separately on every commit
echo "canary not supported as explicit tag"
exit 1
fi
echo "Publishing tag: ${tag}"
npm publish --tag "${tag}"
curl "https://purge.jsdelivr.net/npm/hls.js@${tag}"
echo "Published."
fi
else
echo "Already published."
fi
fi
npm run docs
./scripts/build-netlify.sh
if [ "${TRAVIS_MODE}" != "netlifyPr" ]; then
./scripts/deploy-netlify.sh
fi
else
echo "Unknown travis mode: ${TRAVIS_MODE}" 1>&2
exit 1
fi