-# 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
+name: Release
on:
release:
env:
TAG: ${{ github.event.release.tag_name }}
- test:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - name: Use Node.js
- uses: actions/setup-node@v1
- - name: Test
- run: |
- npm ci
- xvfb-run --auto-servernum npm test
-
- publish-npm:
- needs: [test, setup]
+ release:
+ needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
json -I -f package.json -e "this.version=\"$VERSION\""
json -I -f package-lock.json -e "this.version=\"$VERSION\""
npm run build
- ./scripts/docs-config.sh "${VERSION}"
+ ./scripts/docs-config.sh "$VERSION" release
npm run docs
npm pack
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
VERSION: ${{ needs.setup.outputs.version }}
- name: Deploy Docs
- run: ./scripts/deploy-docs.sh "$VERSION"
+ run: ./scripts/deploy-docs.sh "$VERSION" release
env:
GITHUB_TOKEN: ${{ secrets.GH_AUTH_TOKEN }}
GH_AUTH_EMAIL: ${{ secrets.GH_AUTH_EMAIL }}
asset_path: ${{ format('chart.js-{0}.tgz', needs.setup.outputs.version) }}
asset_name: ${{ format('chart.js-{0}.tgz', needs.setup.outputs.version) }}
asset_content_type: application/gzip
+ release-tag:
+ needs: [setup,release]
+ runs-on: ubuntu-latest
+ if: "!github.event.release.prerelease"
+ steps:
+ - uses: actions/checkout@v2
+ - uses: actions/setup-node@v1
+ with:
+ node-version: '14.x'
+ registry-url: https://registry.npmjs.org/
+ - name: Setup and build
+ run: |
+ npm ci
+ npm install -g json
+ json -I -f package.json -e "this.version=\"$VERSION\""
+ json -I -f package-lock.json -e "this.version=\"$VERSION\""
+ npm run build
+ ./scripts/docs-config.sh "$VERSION"
+ npm run docs
+ env:
+ VERSION: ${{ needs.setup.outputs.version }}
+ - name: Deploy Docs
+ run: ./scripts/deploy-docs.sh "$VERSION"
+ env:
+ GITHUB_TOKEN: ${{ secrets.GH_AUTH_TOKEN }}
+ GH_AUTH_EMAIL: ${{ secrets.GH_AUTH_EMAIL }}
+ VERSION: ${{ needs.setup.outputs.version }}
set -e
+source utils.sh
+
TARGET_DIR='gh-pages'
TARGET_BRANCH='master'
TARGET_REPO_URL="https://$GITHUB_TOKEN@github.com/chartjs/chartjs.github.io.git"
VERSION=$1
+MODE=$2
+TAG=$(tag_from_version "$VERSION" "$MODE")
function move_sample_redirect {
local tag=$1
sed -i -E "s/TAG/$tag/g" samples/$tag/index.html
}
-function update_with_tag {
+function deploy_tagged_files {
local tag=$1
rm -rf "docs/$tag"
cp -r ../dist/docs docs/$tag
deploy_versioned_files $tag
}
-# Note: this code also exists in docs-config.sh
-# tag is next|latest|master
-# https://www.chartjs.org/docs/$tag/
-# https://www.chartjs.org/dist/$tag/chart.*js
-function update_tagged_files {
- if [ "$VERSION" == "master" ]; then
- update_with_tag master
- elif [[ "$VERSION" =~ ^[^-]+$ ]]; then
- update_with_tag latest
- else
- update_with_tag next
- fi
-}
-
function deploy_versioned_files {
local version=$1
local in_files='../dist/chart*.js'
cd $TARGET_DIR
git checkout $TARGET_BRANCH
-# Copy distribution files
-deploy_versioned_files $VERSION
+# https://www.chartjs.org/dist/$VERSION
+if [["$VERSION" != "$TAG"]] then
+ deploy_versioned_files $VERSION
+fi
-update_tagged_files
+# https://www.chartjs.org/dist/$TAG
+# https://www.chartjs.org/docs/$TAG
+# https://www.chartjs.org/samples/$TAG
+deploy_tagged_files $TAG
git add --all
set -e
+source utils.sh
+
VERSION=$1
+MODE=$2
-# Note: this code also exists in deploy.sh
-# tag is next|latest|master
-# https://www.chartjs.org/docs/$tag/
-function update_config {
- local tag=''
- if [ "$VERSION" == "master" ]; then
- tag=master
- elif [[ "$VERSION" =~ ^[^-]+$ ]]; then
- tag=latest
- else
- tag=next
- fi
- sed -i -e "s/VERSION/$tag/g" "docs/.vuepress/config.js"
-}
+TAG=$(tag_from_version "$VERSION" "$MODE")
-update_config
+sed -i -e "s/VERSION/$TAG/g" "docs/.vuepress/config.js"
--- /dev/null
+#!/bin/bash
+
+# tag is next|latest|master|x.x.x
+# https://www.chartjs.org/dist/$tag/
+# https://www.chartjs.org/docs/$tag/
+# https://www.chartjs.org/samples/$tag/
+function tag_from_version {
+ local version=$1
+ local mode=$2
+ local tag=''
+ if [ "$version" == "master" ]; then
+ tag=master
+ elif [[ "$version" =~ ^[^-]+$ ]]; then
+ if [[ "$mode" == "release" ]]
+ tag=$version
+ else
+ tag=latest
+ fi
+ else
+ tag=next
+ fi
+ echo $tag
+}