I wrote a workflow to generate documents with nimble doc and release to GitHub Pages in GitHub Actions.
This workflow deploys HTML to gh-pages branch. See also: About GitHub Pages - GitHub Docs
name: docs
on:
push:
tags:
- 'v*.*.*'
env:
nim-version: stable
nim-src: src/YOUR_PROGRAM.nim
deploy-dir: .gh-pages
jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: jiro4989/setup-nim-action@v1
with:
nim-version: ${{ env.nim-version }}
- run: nimble doc --index:on --project --out:${{ env.deploy-dir }} ${{ env.nim-src }}
- name: Deploy documents
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ${{ env.deploy-dir }}
CI runs when you create a new tags.
$ git tag v0.1.0
$ git push origin v0.1.0
Generated document is below.
https://jiro4989.github.io/faker/faker.html
If you want to generate documents when master branch was updated, change below.
on:
push:
branches:
- master
Examples: https://github.com/jiro4989/faker/blob/master/.github/workflows/docs.yml
Wassup twenty/twenty? Haha
I would change nim-src env to:
nim-src: src/${{ github.event.repository.name }}.nim
and, optionally add a new step after nimble doc, to rename pkgname.html to index.html
run: mv ${{ env.deploy-dir }}/${{ github.event.repository.name }}.html ${{ env.deploy-dir }}/index.htm
name: docs
on:
push:
tags:
- '*.*.*'
env:
nim-version: 'stable'
nim-src: src/${{ github.event.repository.name }}.nim
deploy-dir: .gh-pages
jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: jiro4989/setup-nim-action@v1
with:
nim-version: ${{ env.nim-version }}
- run: nimble install -Y
- run: nimble doc --index:on --project --out:${{ env.deploy-dir }} ${{ env.nim-src }}
- name: "Rename to index.html"
run: mv ${{ env.deploy-dir }}/${{ github.event.repository.name }}.html ${{ env.deploy-dir }}/index.html
- name: Deploy documents
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ${{ env.deploy-dir }}