shell: bash
- name: Build and Test
run: |
- npm install
+ npm ci
npm run build
npm test
- name: Package
--- /dev/null
+# This workflow publishes new documentation to https://chartjs.org/docs/master after every commit
+name: CI
+
+on:
+ push:
+ branches:
+ - master
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Use Node.js
+ uses: actions/setup-node@v1
+ - name: Package & Deploy Docs
+ run: |
+ npm ci
+ npm run build
+ ./scripts/docs-config.sh "master"
+ npm run docs
+ npm run typedoc
+ npm pack
+ ./scripts/deploy-docs.sh "master"
+ env:
+ GITHUB_TOKEN: ${{ secrets.GH_AUTH_TOKEN }}
+ GH_AUTH_EMAIL: ${{ secrets.GH_AUTH_EMAIL }}
--- /dev/null
+# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
+# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
+
+name: Node.js Package
+
+on:
+ release:
+ types: [published]
+
+jobs:
+ test:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Use Node.js
+ uses: actions/setup-node@v1
+ - name: Setup xvfb
+ run: |
+ Xvfb :99 -screen 0 1024x768x24 &
+ echo "::set-env name=DISPLAY:::99.0"
+ - name: Test
+ run: |
+ npm ci
+ npm test
+
+ publish-npm:
+ needs: test
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - uses: actions/setup-node@v1
+ with:
+ node-version: 12
+ registry-url: https://registry.npmjs.org/
+ # Since we created the release in the UI, we need to find it.
+ # This step gets the release from the GITHUB_REF env var
+ - name: Get release
+ id: get_release
+ uses: bruceadams/get-release@v1.2.2
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ - name: Setup and build
+ run: |
+ npm ci
+ npm install -g json
+ json -I -f package.json -e "this.version=\"$GITHUB_REF\""
+ json -I -f package-lock.json -e "this.version=\"$GITHUB_REF\""
+ npm run build
+ ./scripts/docs-config.sh "${GITHUB_REF:1}"
+ npm run docs
+ npm run typedoc
+ npm pack
+ - name: Publish to NPM
+ run: ./scripts/publish.sh
+ env:
+ NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
+ # On releases, GITHUB_REF is the tag name which is the version
+ # However, it will include the leading "v", so we need to strip that
+ # first character off here since we want the docs folder to not have
+ # the "v" in it.
+ - name: Deploy Docs
+ run: ./scripts/deploy-docs.sh "${GITHUB_REF:1}"
+ env:
+ GITHUB_TOKEN: ${{ secrets.GH_AUTH_TOKEN }}
+ GH_AUTH_EMAIL: ${{ secrets.GH_AUTH_EMAIL }}
+ - name: Upload NPM package file
+ id: upload-npm-package-file
+ uses: actions/upload-release-asset@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ upload_url: ${{ steps.get_release.outputs.upload_url }}
+ asset_path: chart.js-$GITHUB_REF.tgz
+ asset_name: chart.js-$GITHUB_REF.tgz
+ asset_content_type: application/gzip
+++ /dev/null
-language: node_js
-node_js:
- - lts/*
-
-before_install:
- - "export CHROME_BIN=/usr/bin/google-chrome"
-
-services:
- - xvfb
-
-script:
- - npm run build
- - npm test
- - ./scripts/docs-config.sh
- - npm run docs
- - npm run typedoc
- - npm pack
- - cat ./coverage/lcov.info | ./node_modules/.bin/coveralls || true
-
-sudo: required
-dist: bionic
-
-addons:
- chrome: stable
- firefox: latest
-
-# IMPORTANT: scripts require GITHUB_AUTH_TOKEN and GITHUB_AUTH_EMAIL environment variables
-# IMPORTANT: scripts has to be set executables in the Git repository (error 127)
-# https://github.com/travis-ci/travis-ci/issues/5538#issuecomment-225025939
-
-deploy:
-- provider: script
- script: ./scripts/deploy.sh
- skip_cleanup: true
- on:
- all_branches: true
-- provider: script
- script: ./scripts/release.sh
- skip_cleanup: true
- on:
- all_branches: true
- condition: $TRAVIS_BRANCH =~ ^(release.*)$
-- provider: releases
- api_key: $GITHUB_AUTH_TOKEN
- skip_cleanup: true
- file_glob: true
- file:
- - ./dist/*.css
- - ./dist/*.js
- - ./dist/*.zip
- on:
- tags: true
-- provider: npm
- email: $NPM_AUTH_EMAIL
- api_key: $NPM_AUTH_TOKEN
- skip_cleanup: true
- on:
- tags: true
- tag: next
<p align="center">
<a href="https://www.chartjs.org/docs/latest/getting-started/installation.html"><img src="https://img.shields.io/github/release/chartjs/Chart.js.svg?style=flat-square&maxAge=600" alt="Downloads"></a>
- <a href="https://travis-ci.org/chartjs/Chart.js"><img src="https://img.shields.io/travis/chartjs/Chart.js.svg?style=flat-square&maxAge=600" alt="Builds"></a>
+ <a href="https://github.com/chartjs/Chart.js/actions?query=workflow%3ACI+branch%3Amaster"><img alt="GitHub Workflow Status" src="https://img.shields.io/github/workflow/status/chartjs/Chart.js/CI"></a>
<a href="https://coveralls.io/github/chartjs/Chart.js?branch=master"><img src="https://img.shields.io/coveralls/chartjs/Chart.js.svg?style=flat-square&maxAge=600" alt="Coverage"></a>
<a href="https://github.com/chartjs/awesome"><img src="https://awesome.re/badge-flat2.svg" alt="Awesome"></a>
<a href="https://chartjs-slack.herokuapp.com/"><img src="https://img.shields.io/badge/slack-chartjs-blue.svg?style=flat-square&maxAge=3600" alt="Slack"></a>
TARGET_DIR='gh-pages'
TARGET_BRANCH='master'
-TARGET_REPO_URL="https://$GITHUB_AUTH_TOKEN@github.com/chartjs/chartjs.github.io.git"
+TARGET_REPO_URL="https://$GITHUB_TOKEN@github.com/chartjs/chartjs.github.io.git"
-# Note: this code also exists in docs-config.sh
-# Make sure that this script is executed only for the release and master branches
-VERSION_REGEX='[[:digit:]]+.[[:digit:]]+.[[:digit:]]+(-.*)?'
-if [[ "$TRAVIS_BRANCH" =~ ^release.*$ ]]; then
- # Travis executes this script from the repository root, so at the same level than package.json
- VERSION=$(node -p -e "require('./package.json').version")
-elif [ "$TRAVIS_BRANCH" == "master" ]; then
- VERSION="master"
-else
- echo "Skipping deploy because this is not the master or release branch"
- exit 0
-fi
+VERSION=$1
function move_sample_scripts {
local subdirectory=$1
if [ "$VERSION" == "master" ]; then
update_with_tag master
elif [[ "$VERSION" =~ ^[^-]+$ ]]; then
- update_with_tag lastest
+ update_with_tag latest
else
update_with_tag next
fi
git add --all
git remote add auth-origin $TARGET_REPO_URL
-git config --global user.email "$GITHUB_AUTH_EMAIL"
+git config --global user.email "$GH_AUTH_EMAIL"
git config --global user.name "Chart.js"
-git commit -m "Deploy $VERSION from $TRAVIS_REPO_SLUG" -m "Commit: $TRAVIS_COMMIT"
+git commit -m "Deploy $VERSION from $GITHUB_REPOSITORY" -m "Commit: $GITHUB_SHA"
git push -q auth-origin $TARGET_BRANCH
git remote rm auth-origin
set -e
-# Note: this code also exists in deploy.sh
-# Make sure that this script is executed only for the release and master branches
-VERSION_REGEX='[[:digit:]]+.[[:digit:]]+.[[:digit:]]+(-.*)?'
-if [[ "$TRAVIS_BRANCH" =~ ^release.*$ ]]; then
- # Travis executes this script from the repository root, so at the same level than package.json
- VERSION=$(node -p -e "require('./package.json').version")
-elif [ "$TRAVIS_BRANCH" == "master" ]; then
- VERSION="master"
-else
- echo "Skipping docs configuration because this is not the master or release branch"
- exit 0
-fi
+VERSION=$1
# Note: this code also exists in deploy.sh
# tag is next|latest|master
if [ "$VERSION" == "master" ]; then
tag=master
elif [[ "$VERSION" =~ ^[^-]+$ ]]; then
- tag=lastest
+ tag=latest
else
tag=next
fi
--- /dev/null
+#!/bin/bash
+
+set -e
+
+NPM_TAG="next"
+
+if [[ "$GITHUB_REF" =~ ^[^-]+$ ]]; then
+ echo "Release tag indicates a full release. Releasing as \"latest\"."
+ NPM_TAG="latest"
+fi
+
+npm publish --tag "$NPM_TAG"
+++ /dev/null
-#!/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
-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}