Skip to content

Commit

Permalink
Documentation versioning (#492)
Browse files Browse the repository at this point in the history
* Documentation versioning

* master instead of $VERSION
  • Loading branch information
kurkle committed Nov 16, 2021
1 parent 43bbcc8 commit 84462ea
Show file tree
Hide file tree
Showing 6 changed files with 300 additions and 3 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/documentation.yml
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
checks:
if: github.event_name != 'push'
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -20,7 +20,7 @@ jobs:
npm ci
npm run docs
gh-release:
if: github.event_name != 'pull_request'
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -30,9 +30,11 @@ jobs:
- name: Build
run: |
npm ci
./scripts/docs-config.sh master
npm run docs
- name: Release to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GH_AUTH_TOKEN }}
publish_dir: dist/docs
destination_dir: master
27 changes: 27 additions & 0 deletions .github/workflows/npmpublish.yml
Expand Up @@ -57,3 +57,30 @@ jobs:
if: "!github.event.release.prerelease"
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
- name: Build docs
run: |
./scripts/docs-config.sh "$VERSION" release
npm run docs
env:
VERSION: ${{ needs.setup.outputs.version }}
- name: Release to GitHub Pages (version)
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GH_AUTH_TOKEN }}
publish_dir: dist/docs
destination_dir: ${{ needs.setup.outputs.version }}
- name: Release to GitHub Pages (latest)
if: "!github.event.release.prerelease"
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GH_AUTH_TOKEN }}
publish_dir: dist/docs
destination_dir: latest
- name: Release to GitHub Pages (next)
if: "github.event.release.prerelease"
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GH_AUTH_TOKEN }}
publish_dir: dist/docs
destination_dir: next

45 changes: 44 additions & 1 deletion docs/.vuepress/config.js
@@ -1,19 +1,62 @@
const docsVersion = "VERSION";
const base = process.env.NODE_ENV === "development" ? '/chartjs-plugin-annotation/master/' : `/chartjs-plugin-annotation/${docsVersion}/`;

module.exports = {
dest: 'dist/docs',
title: 'chartjs-plugin-annotation',
description: 'Annotations for Chart.js',
theme: 'chartjs',
base: '/chartjs-plugin-annotation/',
base,
head: [
['link', {rel: 'icon', href: '/favicon.png'}],
],
plugins: [
['flexsearch'],
['redirect', {
redirectors: [
// Default sample page when accessing /samples.
{base: '/samples', alternative: ['types/line']},
],
}],
['@simonbrunel/vuepress-plugin-versions', {
filters: {
suffix: (tag) => tag ? ` (${tag})` : '',
title: (v, vars) => window.location.href.includes('master') ? 'Development (master)' : v + (vars.tag ? ` (${tag})` : ''),
},
menu: {
text: '{{version|title}}',
items: [
{
text: 'Documentation',
items: [
{
text: 'Development (master)',
link: '/chartjs-plugin-annotation/master/',
},
{
type: 'versions',
text: '{{version}}{{tag|suffix}}',
link: '/chartjs-plugin-annotation/{{version}}/',
exclude: /^[0]\.[0-4]\./,
group: 'minor',
}
]
},
{
text: 'Release notes (5 latest)',
items: [
{
type: 'versions',
limit: 5,
target: '_blank',
group: 'patch',
link: 'https://github.com/chartjs/chartjs-plugin-annotation/releases/tag/v{{version}}'
}
]
}
]
},
}],
],
themeConfig: {
repo: 'chartjs/chartjs-plugin-annotation',
Expand Down

0 comments on commit 84462ea

Please sign in to comment.