Skip to content

Commit 3549f44

Browse files
authored
Add release-drafter and publish-npm workflows (#419)
* Add release-drafter workflow * Add publish-npm action
1 parent 4c016c3 commit 3549f44

File tree

8 files changed

+167
-100
lines changed

8 files changed

+167
-100
lines changed

.github/release-drafter.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name-template: 'v$RESOLVED_VERSION'
2+
tag-template: 'v$RESOLVED_VERSION'
3+
categories:
4+
- title: 'Breaking Changes'
5+
labels:
6+
- 'breaking change'
7+
- title: 'Enhancements'
8+
labels:
9+
- 'enhancement'
10+
- title: 'Bugs Fixed'
11+
labels:
12+
- 'bug'
13+
- title: 'Types'
14+
labels:
15+
- 'types'
16+
- title: 'Documentation'
17+
labels:
18+
- 'documentation'
19+
- title: 'Development'
20+
labels:
21+
- 'chore'
22+
exclude-labels:
23+
- 'infrastructure'
24+
change-template: '- #$NUMBER $TITLE'
25+
change-title-escapes: '\<*_&`#@'
26+
version-resolver:
27+
major:
28+
labels:
29+
- 'breaking change'
30+
minor:
31+
labels:
32+
- 'enhancement'
33+
patch:
34+
labels:
35+
- 'bug'
36+
- 'chore'
37+
- 'types'
38+
default: patch
39+
template: |
40+
# Essential Links
41+
42+
* [npm](https://www.npmjs.com/package/chartjs-plugin-zoom)
43+
44+
$CHANGES
45+
46+
Thanks to $CONTRIBUTORS

.github/workflows/publish-npm.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Publish to npm
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
setup:
9+
runs-on: ubuntu-latest
10+
outputs:
11+
version: ${{ steps.trim.outputs.version }}
12+
steps:
13+
- id: trim
14+
run: echo "::set-output name=version::${TAG:1}"
15+
env:
16+
TAG: ${{ github.event.release.tag_name }}
17+
18+
test:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: Use Node.js
23+
uses: actions/setup-node@v1
24+
- name: Test
25+
run: |
26+
npm ci
27+
xvfb-run --auto-servernum npm test
28+
29+
publish-npm:
30+
needs: [test, setup]
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@v2
34+
- uses: actions/setup-node@v1
35+
with:
36+
node-version: 12
37+
registry-url: https://registry.npmjs.org/
38+
- name: Setup and build
39+
run: |
40+
npm ci
41+
npm run build
42+
npm pack
43+
- name: Publish @next
44+
run: npm publish --tag next
45+
if: "github.event.release.prerelease"
46+
env:
47+
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
48+
- name: Publish @latest
49+
run: npm publish --tag latest --dry-run
50+
if: "!github.event.release.prerelease"
51+
env:
52+
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
53+
- name: Upload chartjs-plugin-zoom.tgz
54+
uses: actions/upload-release-asset@v1
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
with:
58+
upload_url: ${{ github.event.release.upload_url }}
59+
asset_path: ${{ format('chartjs-plugin-zoom-{0}.tgz', needs.setup.outputs.version) }}
60+
asset_name: ${{ format('chartjs-plugin-zoom-{0}.tgz', needs.setup.outputs.version) }}
61+
asset_content_type: application/gzip
62+
- name: Upload chartjs-plugin-zoom.js
63+
uses: actions/upload-release-asset@v1
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
with:
67+
upload_url: ${{ github.event.release.upload_url }}
68+
asset_path: dist/chartjs-plugin-zoom.js
69+
asset_name: chartjs-plugin-zoom.js
70+
asset_content_type: application/javascript
71+
- name: Upload chartjs-plugin-zoom.min.js
72+
uses: actions/upload-release-asset@v1
73+
env:
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75+
with:
76+
upload_url: ${{ github.event.release.upload_url }}
77+
asset_path: dist/chartjs-plugin-zoom.min.js
78+
asset_name: chartjs-plugin-zoom.min.js
79+
asset_content_type: application/javascript
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Release Drafter
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
correct_repository:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: fail on fork
13+
if: github.repository_owner != 'chartjs'
14+
run: exit 1
15+
16+
update_release_draft:
17+
needs: correct_repository
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: release-drafter/release-drafter@v5
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.npmignore

Lines changed: 0 additions & 9 deletions
This file was deleted.

.travis.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

MAINTAINING.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,33 @@
22

33
## Release Process
44

5-
Chart.js relies on [Travis CI](https://travis-ci.org/) to automate the library [releases](https://github.com/chartjs/chartjs-plugin-zoom/releases).
5+
Series of github actions are used to automate the library [releases](https://github.com/chartjs/chartjs-plugin-zoom/releases).
66

77
### Releasing a New Version
88

9-
1. draft release notes on [GitHub](https://github.com/chartjs/chartjs-plugin-zoom/releases/new) for the upcoming tag
10-
1. update `master` `package.json` version using [semver](https://semver.org/) semantic
11-
1. merge `master` into the `release` branch
12-
1. follow the build process on [Travis CI](https://travis-ci.org/chartjs/chartjs-plugin-zoom)
9+
`release-drafter` action updates a draft of release notes after each push. Its based on labels and the commit messages, so its important to label pull requests and have clean commits. If the draft contains commits that do not fall under any heading, those commits should be labeled and the drafter re-run from [actions](https://github.com/chartjs/chartjs-plugin-zoom/actions).
1310

14-
> **Note:** if `master` is merged in `release` with a `package.json` version that already exists, the tag creation fails and the release process is aborted.
11+
1. update `master` `package.json` version using [semver](https://semver.org/) semantic
12+
1. update the tag and version in the release draft to match `package.json`. Mark it as `pre-release` if you would like to publis with `next` tag on [npmjs](https://www.npmjs.com/package/chartjs-plugin-zoom)
13+
1. publish the release in GitHub. Publishing will trigger the `publish-npm` action. You can monitor the process in [actions](https://github.com/chartjs/chartjs-plugin-zoom/actions)
1514

1615
### Automated Tasks
1716

18-
Merging into the `release` branch kicks off the automated release process:
17+
#### release-drafter
1918

20-
* build of the `dist/*.js` files
21-
* `dist/*.js` is copied to the root directory
22-
* `dist/*.js` is added to a detached branch
23-
* a tag is created from the `package.json` version
24-
* tag (with dist files) is pushed to GitHub
19+
Triggered for each push to master. Creates or updates a draft of release notes for next release.
20+
21+
#### compressed-size
2522

26-
Creation of this tag triggers a new build:
23+
Triggered for each pull-request. Calculates the compressed size compared to master. Result can be seen in the action log.
2724

28-
* `chartjs-plugin-zoom.zip` package is generated, containing dist files and examples
29-
* `dist/*.js` and `chartjs-plugin-zoom.zip` are attached to the GitHub release (downloads)
25+
#### npm-publish
26+
27+
Publishing a GitHub release off the automated release process:
28+
29+
* build of the `dist/*.js` files
30+
* `chartjs-plugin-zoom-{version}.tgz` package is generated, containing dist files and examples
31+
* `dist/*.js` and `chartjs-plugin-zoom-{version}.tgz` are attached to the GitHub release tag
3032
* a new npm package is published on [npmjs](https://www.npmjs.com/package/chartjs-plugin-zoom)
3133

3234
Finally, [cdnjs](https://cdnjs.com/libraries/chartjs-plugin-zoom) is automatically updated from the npm release.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
"build": "rollup -c",
1616
"test": "gulp test"
1717
},
18+
"files": [
19+
"dist/*.js"
20+
],
1821
"devDependencies": {
1922
"chart.js": "^3.0.0-beta.7",
2023
"coveralls": "^3.1.0",

scripts/release.sh

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)