Skip to content

Commit 9f45ee1

Browse files
authored
feat: generate new version of doc for each release (#355)
* docs: Publish latest version when there is a new push on main branch + rename develop version to main
1 parent fcfba23 commit 9f45ee1

File tree

4 files changed

+489
-671
lines changed

4 files changed

+489
-671
lines changed

.github/workflows/on-docs-change.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Auto publish docs to version "develop"
1+
name: on-docs-change
22

33
on:
44
push:
@@ -32,27 +32,27 @@ jobs:
3232
- name: Install dependencies
3333
run: |
3434
pip install --upgrade pip
35-
pip install mike==1.1.2 mkdocs-material==8.0.5 mkdocs-git-revision-date-plugin==0.3.1
35+
pip install -r docs/requirements.txt
3636
npm ci
3737
- name: Setup doc deploy
3838
run: |
3939
git config --global user.name Docs deploy
4040
git config --global user.email [email protected]
41-
- name: Build mkdocs site in 'gh-pages' branch and push
41+
- name: Build mkdocs site in "gh-pages" branch and push
4242
run: |
4343
rm -rf site
44-
VERSION="develop"
44+
VERSION="main"
4545
ALIAS="stage"
4646
mkdocs build
4747
mike deploy --push --update-aliases "$VERSION" "$ALIAS"
4848
- name: Build API documentation site
4949
run: |
5050
rm -rf api
5151
npm run docs-generateApiDoc
52-
- name: Deploy API documentation site (copy to "gh-pages" branch inside the version folder)
52+
- name: Release API docs to the main version
5353
uses: peaceiris/actions-gh-pages@v3
5454
with:
5555
github_token: ${{ secrets.GITHUB_TOKEN }}
5656
publish_dir: ./api
5757
keep_files: true
58-
destination_dir: develop/api
58+
destination_dir: main/api

.github/workflows/on-release.yml

+49-3
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ jobs:
1414
with:
1515
token: ${{ secrets.GH_PUBLISH_TOKEN }}
1616
fetch-depth: 0
17-
17+
#########################
18+
# Release new version
19+
#########################
1820
- name: "Use NodeJS 14"
1921
uses: actions/setup-node@v2
2022
with:
2123
node-version: '14'
22-
2324
- name: "Setup npm"
2425
run: |
2526
npm set "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}"
26-
2727
- name: Install packages
2828
run: |
2929
npm ci
@@ -46,3 +46,49 @@ jobs:
4646
npx lerna version --conventional-commits --conventional-prerelease --preid beta --create-release github --force-publish=* --yes
4747
fi
4848
npx lerna publish from-git --no-verify-access --yes
49+
#########################
50+
# Generate documentation
51+
#########################
52+
- name: Set up Python
53+
uses: actions/[email protected]
54+
with:
55+
python-version: '3.8'
56+
- name: Set RELEASE_VERSION env var
57+
run: |
58+
RELEASE_VERSION=$(cat packages/commons/package.json | jq '.version' -r)
59+
echo "RELEASE_VERSION=${RELEASE_VERSION:1}" >> $GITHUB_ENV
60+
- name: Install doc generation dependencies
61+
run: |
62+
pip install --upgrade pip
63+
pip install -r docs/requirements.txt
64+
- name: Setup doc deploy
65+
run: |
66+
git config --global user.name Docs deploy
67+
git config --global user.email [email protected]
68+
- name: Build mkdocs site in "gh-pages" branch and push
69+
run: |
70+
rm -rf site
71+
VERSION="$RELEASE_VERSION"
72+
ALIAS="latest"
73+
mkdocs build
74+
mike deploy --push --update-aliases "$VERSION" "$ALIAS"
75+
# Set latest version as a default
76+
mike set-default --push latest
77+
- name: Build API docs
78+
run: |
79+
rm -rf api
80+
npm run docs-generateApiDoc
81+
- name: Release API docs to the released version
82+
uses: peaceiris/actions-gh-pages@v3
83+
with:
84+
github_token: ${{ secrets.GITHUB_TOKEN }}
85+
publish_dir: ./api
86+
keep_files: true
87+
destination_dir: ${{ env.RELEASE_VERSION }}/api
88+
- name: Release API docs to the "latest" version
89+
uses: peaceiris/actions-gh-pages@v3
90+
with:
91+
github_token: ${{ secrets.GITHUB_TOKEN }}
92+
publish_dir: ./api
93+
keep_files: true
94+
destination_dir: latest/api

docs/requirements.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
mike==1.1.2
2+
mkdocs-material==8.0.5
3+
mkdocs-git-revision-date-plugin==0.3.1

0 commit comments

Comments
 (0)