Skip to content

Commit e8a51d8

Browse files
committed
#3033 Deploy dist files and bower.json (tags)
Add a new Travis deploy task to push dist/*.js and bower.json files into tag sources: - requires Travis GITHUB_AUTH_TOKEN and GITHUB_AUTH_EMAIL environment variables - skipped if not built from the "release" branch - release.sh must be executable (see comment) - reads tag version from package.json - fails if tag already exists
1 parent cd50edb commit e8a51d8

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

Diff for: .travis.yml

+9
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ addons:
3333
- google-chrome-stable
3434

3535
deploy:
36+
# Creates a tag containing dist files and bower.json
37+
# Requires GITHUB_AUTH_TOKEN and GITHUB_AUTH_EMAIL environment variables
38+
# IMPORTANT: the script has to be set executable in the Git repository (error 127)
39+
# https://github.com/travis-ci/travis-ci/issues/5538#issuecomment-225025939
40+
- provider: script
41+
script: ./scripts/release.sh
42+
skip_cleanup: true
43+
on:
44+
branch: release
3645
- provider: releases
3746
api_key:
3847
secure: E6JiZzA/Qy+UD1so/rVfqYnMhgU4m0cUsljxyrKIiYKlt/ZXo1XJabNkpEIYLvckrNx+g/4cmidNcuLfrnAZJtUg53qHLxyqMTXa9zAqmxxJ6aIpQpNK25FIEk9Xwm2XZdbI5rrm0ZciP5rcgg0X8/j5+RtnU3ZpTOCVkp0P73A=

Diff for: scripts/release.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
if [ "$TRAVIS_BRANCH" != "release" ]; then
6+
echo "Skipping release because this is not the 'release' branch"
7+
exit 0
8+
fi
9+
10+
# Travis executes this script from the repository root, so at the same level than package.json
11+
VERSION=$(node -p -e "require('./package.json').version")
12+
13+
# Make sure that the associated tag doesn't already exist
14+
GITTAG=$(git ls-remote origin refs/tags/v$VERSION)
15+
if [ "$GITTAG" != "" ]; then
16+
echo "Tag for package.json version already exists, aborting release"
17+
exit 1
18+
fi
19+
20+
git remote add auth-origin https://$GITHUB_AUTH_TOKEN@github.com/$TRAVIS_REPO_SLUG.git
21+
git config --global user.email "$GITHUB_AUTH_EMAIL"
22+
git config --global user.name "Chart.js"
23+
git checkout --detach --quiet
24+
git add -f dist/*.js bower.json
25+
git commit -m "Release $VERSION"
26+
git tag -a "v$VERSION" -m "Version $VERSION"
27+
git push -q auth-origin refs/tags/v$VERSION 2>/dev/null
28+
git remote rm auth-origin
29+
git checkout -f @{-1}

0 commit comments

Comments
 (0)