]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
#3033 Deploy dist files and bower.json (tags)
authorSimon Brunel <simonbrunel@users.noreply.github.com>
Sun, 28 Aug 2016 10:18:18 +0000 (12:18 +0200)
committerSimon Brunel <simonbrunel@users.noreply.github.com>
Sun, 28 Aug 2016 16:21:12 +0000 (18:21 +0200)
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

.travis.yml
scripts/release.sh [new file with mode: 0755]

index df409f0ec884c8d8ab63f175ceb4df0b93989b55..077fddf2f237313b7344af850b80b774148a167e 100644 (file)
@@ -33,6 +33,15 @@ addons:
       - google-chrome-stable
 
 deploy:
+# Creates a tag containing dist files and bower.json
+# Requires GITHUB_AUTH_TOKEN and GITHUB_AUTH_EMAIL environment variables
+# IMPORTANT: the script has to be set executable in the Git repository (error 127)
+# https://github.com/travis-ci/travis-ci/issues/5538#issuecomment-225025939
+- provider: script
+  script: ./scripts/release.sh
+  skip_cleanup: true
+  on:
+    branch: release
 - provider: releases
   api_key:
     secure: E6JiZzA/Qy+UD1so/rVfqYnMhgU4m0cUsljxyrKIiYKlt/ZXo1XJabNkpEIYLvckrNx+g/4cmidNcuLfrnAZJtUg53qHLxyqMTXa9zAqmxxJ6aIpQpNK25FIEk9Xwm2XZdbI5rrm0ZciP5rcgg0X8/j5+RtnU3ZpTOCVkp0P73A=
diff --git a/scripts/release.sh b/scripts/release.sh
new file mode 100755 (executable)
index 0000000..03c7c64
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+set -e
+
+if [ "$TRAVIS_BRANCH" != "release" ]; then
+    echo "Skipping release because this is not the 'release' branch"
+    exit 0
+fi
+
+# Travis executes this script from the repository root, so at the same level than package.json
+VERSION=$(node -p -e "require('./package.json').version")
+
+# Make sure that the associated tag doesn't already exist
+GITTAG=$(git ls-remote origin refs/tags/v$VERSION)
+if [ "$GITTAG" != "" ]; then
+    echo "Tag for package.json version already exists, aborting release"
+    exit 1
+fi
+
+git remote add auth-origin https://$GITHUB_AUTH_TOKEN@github.com/$TRAVIS_REPO_SLUG.git
+git config --global user.email "$GITHUB_AUTH_EMAIL"
+git config --global user.name "Chart.js"
+git checkout --detach --quiet
+git add -f dist/*.js bower.json
+git commit -m "Release $VERSION"
+git tag -a "v$VERSION" -m "Version $VERSION"
+git push -q auth-origin refs/tags/v$VERSION 2>/dev/null
+git remote rm auth-origin
+git checkout -f @{-1}