-
Notifications
You must be signed in to change notification settings - Fork 108
86 lines (71 loc) · 2.79 KB
/
docs.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Update docs
on:
push:
tags:
- "v7.*.*" # all v7 semver release tags
- "v8.*.*" # all v8 semver release tags
branches:
- stable
jobs:
publish-docs:
runs-on: ubuntu-latest
container:
image: node:16
steps:
- name: Checkout current commit
uses: actions/checkout@v2
- name: Checkout gh-pages
uses: actions/checkout@v2
with:
ref: gh-pages
path: gh-pages
- run: apt-get update && apt-get install jq -y
- run: npm install -g npm@7
- run: npm install
- name: Set TAG env to devel
if: startsWith( github.event.ref, 'refs/heads/' )
run: |
echo "TAG=devel" >> $GITHUB_ENV
echo "LATEST=1" >> $GITHUB_ENV
- name: Set TAG env to ref tag
if: startsWith( github.event.ref, 'refs/tags/v' )
run: |
export TAG=$(echo ${{ github.event.ref }} | sed -e 's/^refs\/tags\/v//')
echo "TAG=${TAG}" >> $GITHUB_ENV
echo "LATEST=$(node -p "Number(require('semver').gt('${TAG}','$(cat gh-pages/VERSION)'))")" >> $GITHUB_ENV
- name: Update VERSION / latest
if: env.TAG != 'devel' && env.LATEST == 1
run: |
echo $'---\npermalink: /VERSION\ntitle: "VERSION"\n---\n' > gh-pages/VERSION.md
echo $TAG >> gh-pages/VERSION
ln -s $TAG gh-pages/latest
- name: Update CHANGELOG
if: env.LATEST == 1 # don't overwrite for backport versions
run: |
echo $'---\npermalink: /CHANGELOG\ntitle: "CHANGELOG"\n---\n' > gh-pages/CHANGELOG.md
cat CHANGELOG.md >> gh-pages/CHANGELOG.md
- name: Update MIGRATING
if: env.LATEST == 1 # don't overwrite for backport versions
run: |
echo $'---\npermalink: /MIGRATING\ntitle: "Migrating"\n---\n' > gh-pages/MIGRATING.md
cat MIGRATING.md >> gh-pages/MIGRATING.md
- name: Remove old docs
run: |
rm -rf gh-pages/${TAG}
- name: Rebuild docs for tag
if: env.TAG != 'devel'
run: |
./node_modules/.bin/typedoc --includeVersion --gitRevision ${TAG} --out gh-pages/${TAG}
node -p 'var all=fs.readdirSync("gh-pages",{withFileTypes:true}).flatMap(f=>f.isDirectory()&&!isNaN(f.name.charAt(0))?[f.name]:[]).sort(require("semver").rcompare);JSON.stringify({all,stable:all.filter(s=>!s.includes("-"))})' > gh-pages/_data/versions.json
- name: Rebuild docs for devel
if: env.TAG == 'devel'
run: |
./node_modules/.bin/typedoc --out gh-pages/${TAG}
- name: Commit to gh-pages
uses: EndBug/add-and-commit@v4
with:
cwd: ./gh-pages
ref: gh-pages
message: Update ${{ env.TAG }} docs via ${{ github.sha }}
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}