]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Remove release branch workflow (#7827)
authorEvert Timberg <evert.timberg+github@gmail.com>
Tue, 13 Oct 2020 21:12:19 +0000 (17:12 -0400)
committerGitHub <noreply@github.com>
Tue, 13 Oct 2020 21:12:19 +0000 (17:12 -0400)
* GitHub actions uses locked install for CI
* Add initial GitHub action to publish to NPM
* Detect the NPM tag (latest vs next) depending on the git tag
* Deploy docs from releases & master commits
* Remove Travis CI
* Update repo badge to use actions status
* Remove Travis env vars and update docs-config to take a parameter
* Update publish script regex to match other scripts
* Deploy docs action only runs in one spot

.github/workflows/ci.yml
.github/workflows/deploy-docs.yml [new file with mode: 0644]
.github/workflows/npmpublish.yml [new file with mode: 0644]
.travis.yml [deleted file]
README.md
scripts/deploy-docs.sh [moved from scripts/deploy.sh with 65% similarity, mode: 0644]
scripts/docs-config.sh
scripts/publish.sh [new file with mode: 0644]
scripts/release.sh [deleted file]

index 15a6d79c7253d1055cb82b00241460571367a915..b366dba83ff9a0833cf1ca8935e1d8533824b618 100644 (file)
@@ -41,7 +41,7 @@ jobs:
       shell: bash
     - name: Build and Test
       run: |
-        npm install
+        npm ci
         npm run build
         npm test
     - name: Package
diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml
new file mode 100644 (file)
index 0000000..e6c7e2f
--- /dev/null
@@ -0,0 +1,28 @@
+# 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 }}
diff --git a/.github/workflows/npmpublish.yml b/.github/workflows/npmpublish.yml
new file mode 100644 (file)
index 0000000..8565c04
--- /dev/null
@@ -0,0 +1,75 @@
+# 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
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644 (file)
index 4983aef..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-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
index b75d1b66a87b12964dba1df2640b7a631bdbf97f..33e7b811c1ecbfa4fd5c5b41ee43f4d46584f36e 100644 (file)
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@
 
 <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>
old mode 100755 (executable)
new mode 100644 (file)
similarity index 65%
rename from scripts/deploy.sh
rename to scripts/deploy-docs.sh
index 497ba65..128cda6
@@ -4,20 +4,9 @@ set -e
 
 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
@@ -47,7 +36,7 @@ function update_tagged_files {
     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
@@ -75,9 +64,9 @@ update_tagged_files
 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
 
index ed557f3577a3e82eadbd9b903c91ab2e6a34384a..dd0e39610691f7fbc399d49c5719b981e49afc9a 100755 (executable)
@@ -2,18 +2,7 @@
 
 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
@@ -23,7 +12,7 @@ function update_config {
     if [ "$VERSION" == "master" ]; then
         tag=master
     elif [[ "$VERSION" =~ ^[^-]+$ ]]; then
-        tag=lastest
+        tag=latest
     else
         tag=next
     fi
diff --git a/scripts/publish.sh b/scripts/publish.sh
new file mode 100644 (file)
index 0000000..c10cb71
--- /dev/null
@@ -0,0 +1,12 @@
+#!/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"
diff --git a/scripts/release.sh b/scripts/release.sh
deleted file mode 100755 (executable)
index 53afebc..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/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}