Skip to content

Commit b1d2245

Browse files
authored
Documentation versioning (#596)
* Documentation versioning * Add executable bit
1 parent b1cbd8a commit b1d2245

File tree

6 files changed

+265
-3
lines changed

6 files changed

+265
-3
lines changed

.github/workflows/documentation.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
jobs:
1010
checks:
11-
if: github.event_name != 'push'
11+
if: github.event_name == 'pull_request'
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v2
@@ -18,9 +18,10 @@ jobs:
1818
- name: Test Build
1919
run: |
2020
npm ci
21+
./scripts/docs-config.sh master
2122
npm run docs
2223
gh-release:
23-
if: github.event_name != 'pull_request'
24+
if: github.event_name == 'push'
2425
runs-on: ubuntu-latest
2526
steps:
2627
- uses: actions/checkout@v2
@@ -30,9 +31,11 @@ jobs:
3031
- name: Build
3132
run: |
3233
npm ci
34+
./scripts/docs-config.sh master
3335
npm run docs
3436
- name: Release to GitHub Pages
3537
uses: peaceiris/actions-gh-pages@v3
3638
with:
3739
github_token: ${{ secrets.GH_AUTH_TOKEN }}
3840
publish_dir: dist/docs
41+
destination_dir: master

.github/workflows/publish-npm.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,29 @@ jobs:
7979
asset_path: dist/chartjs-plugin-zoom.min.js
8080
asset_name: chartjs-plugin-zoom.min.js
8181
asset_content_type: application/javascript
82+
- name: Build docs
83+
run: |
84+
./scripts/docs-config.sh "$VERSION" release
85+
npm run docs
86+
env:
87+
VERSION: ${{ needs.setup.outputs.version }}
88+
- name: Release to GitHub Pages (version)
89+
uses: peaceiris/actions-gh-pages@v3
90+
with:
91+
github_token: ${{ secrets.GH_AUTH_TOKEN }}
92+
publish_dir: dist/docs
93+
destination_dir: ${{ needs.setup.outputs.version }}
94+
- name: Release to GitHub Pages (latest)
95+
if: "!github.event.release.prerelease"
96+
uses: peaceiris/actions-gh-pages@v3
97+
with:
98+
github_token: ${{ secrets.GH_AUTH_TOKEN }}
99+
publish_dir: dist/docs
100+
destination_dir: latest
101+
- name: Release to GitHub Pages (next)
102+
if: "github.event.release.prerelease"
103+
uses: peaceiris/actions-gh-pages@v3
104+
with:
105+
github_token: ${{ secrets.GH_AUTH_TOKEN }}
106+
publish_dir: dist/docs
107+
destination_dir: next

docs/.vuepress/config.js

100644100755
Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const path = require('path');
2-
const base = process.env.MY_PLATFORM === "cloudflare" ? '/' : `/chartjs-plugin-zoom/`;
2+
const docsVersion = "VERSION";
3+
const base = process.env.NODE_ENV === "development" ? '/chartjs-plugin-zoom/master/' : `/chartjs-plugin-zoom/${docsVersion}/`;
34

45
module.exports = {
56
title: 'chartjs-plugin-zoom',
@@ -30,6 +31,47 @@ module.exports = {
3031
},
3132
},
3233
],
34+
['@simonbrunel/vuepress-plugin-versions', {
35+
filters: {
36+
suffix: (tag) => tag ? ` (${tag})` : '',
37+
title: (v, vars) => window.location.href.includes('master') ? 'Development (master)' : v + (vars.tag ? ` (${tag})` : ''),
38+
},
39+
menu: {
40+
text: '{{version|title}}',
41+
items: [
42+
{
43+
text: 'Documentation',
44+
items: [
45+
{
46+
text: 'Development (master)',
47+
link: '/chartjs-plugin-zoom/master/',
48+
target: '_self',
49+
},
50+
{
51+
type: 'versions',
52+
text: '{{version}}{{tag|suffix}}',
53+
link: '/chartjs-plugin-zoom/{{version}}/',
54+
exclude: /^[0]\.[0-4]\./,
55+
group: 'minor',
56+
target: '_self',
57+
}
58+
]
59+
},
60+
{
61+
text: 'Release notes (5 latest)',
62+
items: [
63+
{
64+
type: 'versions',
65+
limit: 5,
66+
target: '_blank',
67+
group: 'patch',
68+
link: 'https://github.com/chartjs/chartjs-plugin-zoom/releases/tag/v{{version}}'
69+
}
70+
]
71+
}
72+
]
73+
},
74+
}],
3375
],
3476
chainWebpack: (config) => {
3577
config.merge({

package-lock.json

Lines changed: 160 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
],
3434
"devDependencies": {
3535
"@rollup/plugin-json": "^4.1.0",
36+
"@simonbrunel/vuepress-plugin-versions": "^0.2.0",
3637
"@typescript-eslint/eslint-plugin": "^5.4.0",
3738
"@typescript-eslint/parser": "^5.4.0",
3839
"chart.js": "^3.2.0",

0 commit comments

Comments
 (0)