Skip to content

Commit ff354cc

Browse files
authored
Remove release branch workflow (#7827)
* 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
1 parent d887b0a commit ff354cc

File tree

9 files changed

+124
-119
lines changed

9 files changed

+124
-119
lines changed

Diff for: .github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
shell: bash
4242
- name: Build and Test
4343
run: |
44-
npm install
44+
npm ci
4545
npm run build
4646
npm test
4747
- name: Package

Diff for: .github/workflows/deploy-docs.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This workflow publishes new documentation to https://chartjs.org/docs/master after every commit
2+
name: CI
3+
4+
on:
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Use Node.js
16+
uses: actions/setup-node@v1
17+
- name: Package & Deploy Docs
18+
run: |
19+
npm ci
20+
npm run build
21+
./scripts/docs-config.sh "master"
22+
npm run docs
23+
npm run typedoc
24+
npm pack
25+
./scripts/deploy-docs.sh "master"
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.GH_AUTH_TOKEN }}
28+
GH_AUTH_EMAIL: ${{ secrets.GH_AUTH_EMAIL }}

Diff for: .github/workflows/npmpublish.yml

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
3+
4+
name: Node.js Package
5+
6+
on:
7+
release:
8+
types: [published]
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Use Node.js
16+
uses: actions/setup-node@v1
17+
- name: Setup xvfb
18+
run: |
19+
Xvfb :99 -screen 0 1024x768x24 &
20+
echo "::set-env name=DISPLAY:::99.0"
21+
- name: Test
22+
run: |
23+
npm ci
24+
npm test
25+
26+
publish-npm:
27+
needs: test
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v2
31+
- uses: actions/setup-node@v1
32+
with:
33+
node-version: 12
34+
registry-url: https://registry.npmjs.org/
35+
# Since we created the release in the UI, we need to find it.
36+
# This step gets the release from the GITHUB_REF env var
37+
- name: Get release
38+
id: get_release
39+
uses: bruceadams/get-release@v1.2.2
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
- name: Setup and build
43+
run: |
44+
npm ci
45+
npm install -g json
46+
json -I -f package.json -e "this.version=\"$GITHUB_REF\""
47+
json -I -f package-lock.json -e "this.version=\"$GITHUB_REF\""
48+
npm run build
49+
./scripts/docs-config.sh "${GITHUB_REF:1}"
50+
npm run docs
51+
npm run typedoc
52+
npm pack
53+
- name: Publish to NPM
54+
run: ./scripts/publish.sh
55+
env:
56+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
57+
# On releases, GITHUB_REF is the tag name which is the version
58+
# However, it will include the leading "v", so we need to strip that
59+
# first character off here since we want the docs folder to not have
60+
# the "v" in it.
61+
- name: Deploy Docs
62+
run: ./scripts/deploy-docs.sh "${GITHUB_REF:1}"
63+
env:
64+
GITHUB_TOKEN: ${{ secrets.GH_AUTH_TOKEN }}
65+
GH_AUTH_EMAIL: ${{ secrets.GH_AUTH_EMAIL }}
66+
- name: Upload NPM package file
67+
id: upload-npm-package-file
68+
uses: actions/upload-release-asset@v1
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
with:
72+
upload_url: ${{ steps.get_release.outputs.upload_url }}
73+
asset_path: chart.js-$GITHUB_REF.tgz
74+
asset_name: chart.js-$GITHUB_REF.tgz
75+
asset_content_type: application/gzip

Diff for: .travis.yml

-59
This file was deleted.

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<p align="center">
77
<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>
8-
<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>
8+
<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>
99
<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>
1010
<a href="https://github.com/chartjs/awesome"><img src="https://awesome.re/badge-flat2.svg" alt="Awesome"></a>
1111
<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>

Diff for: scripts/deploy.sh renamed to scripts/deploy-docs.sh

+5-16
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,9 @@ set -e
44

55
TARGET_DIR='gh-pages'
66
TARGET_BRANCH='master'
7-
TARGET_REPO_URL="https://$GITHUB_AUTH_TOKEN@github.com/chartjs/chartjs.github.io.git"
7+
TARGET_REPO_URL="https://$GITHUB_TOKEN@github.com/chartjs/chartjs.github.io.git"
88

9-
# Note: this code also exists in docs-config.sh
10-
# Make sure that this script is executed only for the release and master branches
11-
VERSION_REGEX='[[:digit:]]+.[[:digit:]]+.[[:digit:]]+(-.*)?'
12-
if [[ "$TRAVIS_BRANCH" =~ ^release.*$ ]]; then
13-
# Travis executes this script from the repository root, so at the same level than package.json
14-
VERSION=$(node -p -e "require('./package.json').version")
15-
elif [ "$TRAVIS_BRANCH" == "master" ]; then
16-
VERSION="master"
17-
else
18-
echo "Skipping deploy because this is not the master or release branch"
19-
exit 0
20-
fi
9+
VERSION=$1
2110

2211
function move_sample_scripts {
2312
local subdirectory=$1
@@ -47,7 +36,7 @@ function update_tagged_files {
4736
if [ "$VERSION" == "master" ]; then
4837
update_with_tag master
4938
elif [[ "$VERSION" =~ ^[^-]+$ ]]; then
50-
update_with_tag lastest
39+
update_with_tag latest
5140
else
5241
update_with_tag next
5342
fi
@@ -75,9 +64,9 @@ update_tagged_files
7564
git add --all
7665

7766
git remote add auth-origin $TARGET_REPO_URL
78-
git config --global user.email "$GITHUB_AUTH_EMAIL"
67+
git config --global user.email "$GH_AUTH_EMAIL"
7968
git config --global user.name "Chart.js"
80-
git commit -m "Deploy $VERSION from $TRAVIS_REPO_SLUG" -m "Commit: $TRAVIS_COMMIT"
69+
git commit -m "Deploy $VERSION from $GITHUB_REPOSITORY" -m "Commit: $GITHUB_SHA"
8170
git push -q auth-origin $TARGET_BRANCH
8271
git remote rm auth-origin
8372

Diff for: scripts/docs-config.sh

+2-13
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,7 @@
22

33
set -e
44

5-
# Note: this code also exists in deploy.sh
6-
# Make sure that this script is executed only for the release and master branches
7-
VERSION_REGEX='[[:digit:]]+.[[:digit:]]+.[[:digit:]]+(-.*)?'
8-
if [[ "$TRAVIS_BRANCH" =~ ^release.*$ ]]; then
9-
# Travis executes this script from the repository root, so at the same level than package.json
10-
VERSION=$(node -p -e "require('./package.json').version")
11-
elif [ "$TRAVIS_BRANCH" == "master" ]; then
12-
VERSION="master"
13-
else
14-
echo "Skipping docs configuration because this is not the master or release branch"
15-
exit 0
16-
fi
5+
VERSION=$1
176

187
# Note: this code also exists in deploy.sh
198
# tag is next|latest|master
@@ -23,7 +12,7 @@ function update_config {
2312
if [ "$VERSION" == "master" ]; then
2413
tag=master
2514
elif [[ "$VERSION" =~ ^[^-]+$ ]]; then
26-
tag=lastest
15+
tag=latest
2716
else
2817
tag=next
2918
fi

Diff for: scripts/publish.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
NPM_TAG="next"
6+
7+
if [[ "$GITHUB_REF" =~ ^[^-]+$ ]]; then
8+
echo "Release tag indicates a full release. Releasing as \"latest\"."
9+
NPM_TAG="latest"
10+
fi
11+
12+
npm publish --tag "$NPM_TAG"

Diff for: scripts/release.sh

-29
This file was deleted.

0 commit comments

Comments
 (0)