Skip to content

Commit 52a9fc6

Browse files
authored
docs: add versioning with mike (#88)
1 parent 6d54b91 commit 52a9fc6

4 files changed

Lines changed: 106 additions & 7 deletions

File tree

.github/workflows/docs.yml

Lines changed: 84 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,99 @@ on:
44
push:
55
branches:
66
- develop
7+
8+
tags:
9+
- 'v*'
10+
711
paths:
8-
- 'docs/**/*'
12+
- 'docs/**'
913
- 'mkdocs.yml'
1014
- '.github/workflows/docs.yml'
1115

1216
permissions:
1317
contents: write
1418

19+
concurrency:
20+
group: docs-deploy
21+
cancel-in-progress: false
22+
1523
jobs:
1624
deploy:
1725
runs-on: ubuntu-latest
26+
1827
steps:
19-
- uses: actions/checkout@v6
20-
- uses: actions/setup-python@v6
28+
- name: Checkout repository
29+
uses: actions/checkout@v6
30+
31+
- name: Setup Python
32+
uses: actions/setup-python@v6
2133
with:
22-
python-version: 3.x
23-
- run: pip install mkdocs-material
24-
- run: mkdocs gh-deploy --force
34+
python-version: '3.x'
35+
36+
- name: Install dependencies
37+
run: pip install mkdocs-material mike
38+
39+
- name: Fetch gh-pages
40+
run: git fetch origin gh-pages --depth=1 || true
41+
42+
- name: Configure git
43+
run: |
44+
git config user.name github-actions[bot]
45+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
46+
47+
- name: Deploy docs with mike
48+
shell: bash
49+
run: |
50+
set -e
51+
52+
deploy_version () {
53+
local VERSION="$1"
54+
local UPDATE_LATEST="${2:-false}"
55+
56+
VERSION="${VERSION#v}"
57+
58+
MINOR=$(echo "$VERSION" | sed -E 's/^([0-9]+\.[0-9]+).*/\1/')
59+
60+
echo "Deploying docs version: $MINOR"
61+
62+
if [ "$UPDATE_LATEST" = "true" ]; then
63+
mike deploy --push --update-aliases "$MINOR" latest
64+
return
65+
fi
66+
67+
mike deploy --push "$MINOR"
68+
}
69+
70+
#
71+
# Develop branch
72+
#
73+
if [ "${{ github.ref_type }}" = "branch" ] && [ "${{ github.ref_name }}" = "develop" ]; then
74+
echo "Deploying dev docs"
75+
76+
mike deploy --push dev
77+
78+
exit 0
79+
fi
80+
81+
#
82+
# Release tags
83+
#
84+
if [ "${{ github.ref_type }}" = "tag" ]; then
85+
VERSION="${{ github.ref_name }}"
86+
87+
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
88+
echo "Skipping non-stable release tag: $VERSION"
89+
exit 0
90+
fi
91+
92+
deploy_version "$VERSION" true
93+
94+
echo "Setting default docs version: latest"
95+
96+
mike set-default --push latest
97+
98+
exit 0
99+
fi
100+
101+
echo "Unsupported ref"
102+
exit 1

docs/CNAME

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/overrides/main.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{% extends "base.html" %}
2+
3+
{% block outdated %}
4+
{% if config.site_url.rstrip("/").endswith("/dev") %}
5+
You're viewing the development version.
6+
Some features may not be available in a stable release yet.
7+
<a href="{{ '../' ~ base_url }}">
8+
<strong>Go to the latest stable version.</strong>
9+
</a>
10+
{% else %}
11+
You're not viewing the latest version.
12+
<a href="{{ '../' ~ base_url }}">
13+
<strong>Click here to go to latest.</strong>
14+
</a>
15+
{% endif %}
16+
{% endblock %}

mkdocs.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
site_name: CodeIgniter Queue
22
site_description: Queues documentation for CodeIgniter 4 framework
33

4+
exclude_docs: |
5+
overrides/
6+
47
theme:
58
name: material
9+
custom_dir: docs/overrides
610
logo: assets/flame.svg
711
favicon: assets/favicon.ico
812
icon:
@@ -35,6 +39,8 @@ theme:
3539
extra:
3640
homepage: https://codeigniter.com
3741
generator: false
42+
version:
43+
provider: mike
3844

3945
social:
4046
- icon: material/github

0 commit comments

Comments
 (0)