2020-10-13 23:12:19 +02:00
|
|
|
# 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:
|
2020-11-11 13:25:57 +01:00
|
|
|
setup:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
|
|
version: ${{ steps.trim.outputs.version }}
|
|
|
|
steps:
|
|
|
|
- id: trim
|
|
|
|
run: echo "::set-output name=version::${TAG:1}"
|
|
|
|
env:
|
|
|
|
TAG: ${{ github.event.release.tag_name }}
|
|
|
|
|
2020-10-13 23:12:19 +02:00
|
|
|
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:
|
2020-11-11 13:25:57 +01:00
|
|
|
needs: [test, setup]
|
2020-10-13 23:12:19 +02:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions/setup-node@v1
|
|
|
|
with:
|
|
|
|
node-version: 12
|
|
|
|
registry-url: https://registry.npmjs.org/
|
|
|
|
- name: Setup and build
|
|
|
|
run: |
|
|
|
|
npm ci
|
|
|
|
npm install -g json
|
2020-10-15 22:37:38 +02:00
|
|
|
json -I -f package.json -e "this.version=\"$VERSION\""
|
|
|
|
json -I -f package-lock.json -e "this.version=\"$VERSION\""
|
2020-10-13 23:12:19 +02:00
|
|
|
npm run build
|
2020-11-11 13:25:57 +01:00
|
|
|
./scripts/docs-config.sh "${VERSION}"
|
2020-10-13 23:12:19 +02:00
|
|
|
npm run docs
|
|
|
|
npm run typedoc
|
|
|
|
npm pack
|
2020-10-15 22:37:38 +02:00
|
|
|
env:
|
2020-11-11 13:25:57 +01:00
|
|
|
VERSION: ${{ needs.setup.outputs.version }}
|
2020-10-13 23:12:19 +02:00
|
|
|
- name: Publish to NPM
|
|
|
|
run: ./scripts/publish.sh
|
|
|
|
env:
|
|
|
|
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
2020-11-11 13:25:57 +01:00
|
|
|
VERSION: ${{ needs.setup.outputs.version }}
|
2020-10-13 23:12:19 +02:00
|
|
|
- name: Deploy Docs
|
2020-11-11 13:25:57 +01:00
|
|
|
run: ./scripts/deploy-docs.sh "$VERSION"
|
2020-10-13 23:12:19 +02:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GH_AUTH_TOKEN }}
|
|
|
|
GH_AUTH_EMAIL: ${{ secrets.GH_AUTH_EMAIL }}
|
2020-11-11 13:25:57 +01:00
|
|
|
VERSION: ${{ needs.setup.outputs.version }}
|
2020-10-13 23:12:19 +02:00
|
|
|
- name: Upload NPM package file
|
|
|
|
id: upload-npm-package-file
|
|
|
|
uses: actions/upload-release-asset@v1
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
2020-11-11 13:25:57 +01:00
|
|
|
VERSION: ${{ needs.setup.outputs.version }}
|
2020-10-13 23:12:19 +02:00
|
|
|
with:
|
2020-10-15 22:37:38 +02:00
|
|
|
upload_url: ${{ github.event.release.upload_url }}
|
2020-11-11 13:25:57 +01:00
|
|
|
asset_path: ${{ format('chart.js-{0}.tgz', needs.setup.outputs.version) }}
|
|
|
|
asset_name: ${{ format('chart.js-{0}.tgz', needs.setup.outputs.version) }}
|
2020-10-13 23:12:19 +02:00
|
|
|
asset_content_type: application/gzip
|