Skip to content

Commit 75986c9

Browse files
authored
Merge pull request #6 from febus982/versioned-documentation
Versioned documentation
2 parents 62427b9 + f86031e commit 75986c9

File tree

7 files changed

+120
-71
lines changed

7 files changed

+120
-71
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Deploy static content to Pages
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
# Allows you to run this workflow manually from the Actions tab
7+
workflow_dispatch:
8+
9+
jobs:
10+
site:
11+
uses: ./.github/workflows/reusable-github-pages.yml
12+
with:
13+
site-version: "dev"

.github/workflows/github-pages.yml

Lines changed: 0 additions & 70 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ on:
88

99
jobs:
1010
build:
11+
outputs:
12+
docs-version: ${{ steps.docs-version.outputs.version }}
1113
runs-on: ubuntu-latest
1214
permissions:
1315
contents: read
@@ -36,6 +38,11 @@ jobs:
3638
path: dist
3739
retention-days: 1
3840

41+
- name: Export version for site docs
42+
id: docs-version
43+
run: ./ci-scripts/docs-version.sh >> "$GITHUB_OUTPUT"
44+
45+
3946
publish:
4047
runs-on: ubuntu-latest
4148
needs: build
@@ -64,3 +71,9 @@ jobs:
6471
################################
6572
with:
6673
repository-url: https://test.pypi.org/legacy/
74+
75+
site:
76+
needs: build
77+
uses: ./.github/workflows/reusable-github-pages.yml
78+
with:
79+
site-version: "${{needs.build.outputs.docs-version.version}}"
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
site-version:
5+
required: true
6+
type: string
7+
version-alias:
8+
required: false
9+
type: string
10+
default: ""
11+
branch:
12+
required: false
13+
type: string
14+
default: "gh-pages"
15+
set-default:
16+
required: false
17+
type: boolean
18+
default: false
19+
20+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
21+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
22+
# NOTE: There's no option to not cancel pending jobs, but we should be able to avoid race conditions on
23+
# the published gh-pages branch anyway. The expectation is to have at maximum one running process
24+
# (after merging to main) and one release process waiting.
25+
concurrency:
26+
group: "pages"
27+
cancel-in-progress: false
28+
29+
jobs:
30+
build_deploy_pages:
31+
runs-on: ubuntu-latest
32+
environment:
33+
name: github-pages
34+
35+
permissions:
36+
contents: write
37+
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@v3
41+
42+
- name: Set up Python 3.12
43+
uses: actions/setup-python@v4
44+
with:
45+
python-version: "3.12"
46+
47+
- name: Install dependencies
48+
run: |
49+
python -m pip install --upgrade pip
50+
python -m pip install poetry
51+
poetry config virtualenvs.create false
52+
poetry install --no-root --with dev
53+
54+
- name: Configure Git user
55+
run: |
56+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
57+
git config --local user.name "github-actions[bot]"
58+
59+
- name: Make sure previous versions are available to mike
60+
run: |
61+
git fetch origin gh-pages --depth=1
62+
63+
- name: Build and deploy static pages
64+
run: |
65+
mike deploy ${{ inputs.site-version }} ${{ inputs.version-alias }} --update-aliases --push --branch ${{ inputs.branch }}
66+
67+
- name: Set default site version
68+
if: ${{ inputs.site-default }}
69+
run: |
70+
mike set-default ${{ inputs.set-version }} --push --branch ${{ inputs.branch }}
71+
72+
# `mike` is specifically built to be used together with GitHub pages.
73+
# To upload the website to another service (i.e. AWS S3) uncomment
74+
# the following step to download the rendered HTML documentation to ./site directory.
75+
# You'll need to implement the upload steps for your provider.
76+
77+
# - name: Download artifact to ./site
78+
# run: |
79+
# rm -rf ./site
80+
# git archive -o site.tar ${{ inputs.branch }}
81+
# mkdir -p ./site
82+
# tar xf site.tar -C ./site

ci-scripts/docs-version.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
VERSION=$(poetry version -s)
4+
SEMVER=( ${VERSION//./ } )
5+
echo "version=${SEMVER[0]}.${SEMVER[1]}"

mkdocs.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ docs_dir: docs/
77
repo_name: 'febus982/bootstrap-python-package'
88
repo_url: 'https://github.com/febus982/bootstrap-python-package'
99

10+
plugins:
11+
- search
12+
- mike
13+
1014
theme:
1115
name: material
1216
features:
@@ -15,7 +19,6 @@ theme:
1519
- content.code.copy
1620

1721
palette:
18-
1922
# Palette toggle for light mode
2023
- scheme: default
2124
primary: teal
@@ -34,6 +37,8 @@ extra:
3437
social:
3538
- icon: fontawesome/brands/linkedin
3639
link: https://www.linkedin.com/in/federico-b-a0b78232
40+
version:
41+
provider: mike
3742

3843
nav:
3944
- Home: index.md

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ pytest-cov = ">=4.0.0"
5353
pytest-factoryboy = ">=2.5.0"
5454
pytest-xdist = ">=3.0.2"
5555
ruff = ">=0.0.263"
56+
mike = "^2.0.0"
5657

5758
[tool.pytest.ini_options]
5859
asyncio_mode = "auto"

0 commit comments

Comments
 (0)