Skip to content

Commit 695e719

Browse files
committed
build: release on git tag
After a tag is created: - a new coverage report is generated - a new version of the docs is generated and committed to gh-pages - a new version is deployed to npm
1 parent 4036816 commit 695e719

3 files changed

Lines changed: 63 additions & 0 deletions

File tree

.travis.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,13 @@ script:
55
- npm run lint
66
- npm run test
77
after_success: ./scripts/merge.sh
8+
before_deploy: ./scripts/release.sh
9+
deploy:
10+
provider: npm
11+
email: silvano.luciani@gmail.com
12+
api_key:
13+
secure: W8J++FLVJYKeZL9R5R/tpBJbmaVhYRyjiYDCAFg+HCaX/aa9THql7iYpTlk5ezQw3CXAqPZhWqvoxQMUJNFiAkdmsNhiopD7zInomCzQhlCazWqGsv0a/m5qfdlhlesv31/WZzqr+gA3PEOjG6ED893YMhDi8SluMfHZYbYJPXk=
14+
on:
15+
tags: true
16+
repo: GoogleCloudPlatform/gcloud-node
17+
all_branches: true

scripts/merge.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,17 @@ set -ev
2020
if [ "${TRAVIS_BRANCH}" == "master" ] && [ "${TRAVIS_PULL_REQUEST}" == "false" ]; then
2121
openssl aes-256-cbc -K $encrypted_b8aa0887832a_key -iv $encrypted_b8aa0887832a_iv -in key.json.enc -out key.json -d
2222
npm run regression-test
23+
24+
# generate new set of json files in docs/json/master
25+
npm run docs
26+
git submodule add -b gh-pages https://${GH_OAUTH_TOKEN}@github.com/${GH_OWNER}/${GH_PROJECT_NAME} ghpages
27+
# copy all the docs file that might have changed, excluding versions.txt (to avoid overriding it)
28+
cd docs
29+
cp -R `ls --ignore 'versions.txt'` ../ghpages/
30+
cd ../ghpages
31+
git add .
32+
# commit to gh-pages branch to apply changes
33+
git config user.name "selfiebot"
34+
git commit -m "Update docs after merge to master"
35+
git push https://${GH_OAUTH_TOKEN}@github.com/${GH_OWNER}/${GH_PROJECT_NAME} HEAD:gh-pages
2336
fi

scripts/release.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
3+
# Copyright 2014 Google Inc. All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -ev
18+
19+
# decrypt credentials
20+
openssl aes-256-cbc -K $encrypted_b8aa0887832a_key -iv $encrypted_b8aa0887832a_iv -in key.json.enc -out key.json -d
21+
22+
# create new coverage report
23+
npm run coveralls
24+
25+
### Update docs
26+
# generate new set of json files in docs/json/master
27+
npm run docs
28+
git submodule add -f -b gh-pages https://${GH_OAUTH_TOKEN}@github.com/${GH_OWNER}/${GH_PROJECT_NAME} ghpages
29+
# copy set of json to tag folder
30+
mkdir ghpages/json/${TRAVIS_TAG}
31+
cp -R docs/json/master/* ghpages/json/${TRAVIS_TAG}
32+
cd ghpages
33+
git add json/${TRAVIS_TAG}
34+
# add new tag to versions
35+
echo "${TRAVIS_TAG}" >> versions.txt
36+
git add versions.txt
37+
# commit to gh-pages branch
38+
git config user.name "selfiebot"
39+
git commit -m "Update docs for ${TRAVIS_TAG}"
40+
git push https://${GH_OAUTH_TOKEN}@github.com/${GH_OWNER}/${GH_PROJECT_NAME} HEAD:gh-pages

0 commit comments

Comments
 (0)