Skip to content

Commit 63e39ab

Browse files
committed
Travis: add automated release steps
1 parent c9674f3 commit 63e39ab

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

.travis.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,55 @@ jobs:
1818
- npm run test-unit
1919
- bash <(curl -s https://codecov.io/bash) -c -Z -f .coverage/coverage-final.json -F unit
2020

21+
# create a new release if $CREATE_RELEASE is set
22+
- stage: Create Release
23+
if: env(CREATE_RELEASE) = true AND type = api AND tag IS blank
24+
os: osx
25+
node_js: 12
26+
git:
27+
depth: false # disable --depth
28+
script:
29+
# fail-fast using set -e
30+
- set -e
31+
# decrypt and ssh-add the deploy-key
32+
- openssl aes-256-cbc -K $encrypted_05f822b6caa8_key -iv $encrypted_05f822b6caa8_iv
33+
-in .github/travis-deploy-key.enc -out /tmp/travis-deploy-key -d
34+
- chmod 600 /tmp/travis-deploy-key
35+
- eval "$(ssh-agent -s)"
36+
- ssh-add /tmp/travis-deploy-key
37+
- rm /tmp/travis-deploy-key
38+
# convert remote URL from HTTPS to SSH
39+
- git remote set-url origin $(git config --get remote.origin.url | sed -E 's#(http.*://)([^/]+)/(.+)$#git@\2:\3#g')
40+
- ssh-keyscan github.com >> ~/.ssh/known_hosts
41+
# create release
42+
- npm run release $PUSH_TO_ORIGIN $PRERELEASE_SUFFIX
43+
- set +e
44+
45+
# publish npm package on tagged builds
46+
- stage: Publish Package
47+
if: tag IS present
48+
os: osx
49+
node_js: 12
50+
git:
51+
depth: false # disable --depth
52+
script:
53+
# fail-fast using set -e
54+
- set -e
55+
# get prerelease suffix from version tag
56+
- TAG=$(echo $TRAVIS_TAG | sed 's/^.*-\([a-z]*\).*$/\1/')
57+
# set to `latest` in case of no suffix
58+
- TAG=$([ "${TAG}" = "$TRAVIS_TAG" ] && echo "latest" || echo $TAG)
59+
# make sure `latest` tag is create from master branch
60+
- '[ "$TAG" = "latest" ] && [ $(git rev-parse HEAD) != $(git rev-parse origin/master) ] && return 1 || return 0'
61+
- set +e
62+
deploy:
63+
edge: true # opt in to dpl v2
64+
provider: npm
65+
tag: $TAG
66+
on:
67+
tags: true
68+
all_branches: true
69+
2170
# update gh-pages docs on master
2271
- stage: Publish Docs
2372
if: branch = master

0 commit comments

Comments
 (0)