-
Notifications
You must be signed in to change notification settings - Fork 107
83 lines (69 loc) · 2.75 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
name: Update docs
on:
push:
tags:
- "v*.*.*" # all semver release tags
branches:
- stable
jobs:
publish-docs:
runs-on: ubuntu-latest
container:
image: node:20
steps:
- name: Checkout current commit
uses: actions/checkout@v4
- name: Checkout gh-pages
uses: actions/checkout@v4
with:
ref: gh-pages
path: gh-pages
- run: apt-get update && apt-get install jq -y
- run: npm install -g npm@10
- run: npm install
- name: Set TAG env to devel
if: startsWith( github.event.ref, 'refs/heads/' )
run: |
echo "TAG=devel" >> $GITHUB_ENV
echo "IS_PREVIEW=1" >> $GITHUB_ENV
echo "IS_BACKPORT=0" >> $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 "IS_PREVIEW=$(node -p "Number('${TAG}'.includes('-'))")" >> $GITHUB_ENV
echo "IS_BACKPORT=$(node -p "Number(require('semver').lt('${TAG}','$(tail -n 1 gh-pages/VERSION.md)'))")" >> $GITHUB_ENV
- name: Update VERSION / latest
if: env.IS_PREVIEW != 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 / MIGRATING
if: env.IS_BACKPORT != 1
run: |
echo '---\npermalink: /CHANGELOG\ntitle: "CHANGELOG"\n---\n' > gh-pages/CHANGELOG.md
cat CHANGELOG.md >> gh-pages/CHANGELOG.md
echo '---\npermalink: /MIGRATING\ntitle: "Migration Guide"\n---\n' > gh-pages/MIGRATING.md
cat MIGRATING.md >> gh-pages/MIGRATING.md
- name: Remove old docs if present
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: ${{ github.token }}