10.0.0-alpha.1 #334
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
unlink gh-pages/latest | |
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 }} |