Skip to content

Commit 7e74141

Browse files
authored
Add support and bump to mike 2.0.0 (#174)
This PR upgrades `mike` to 2.0.0. This new version uses symlinks for aliases by default, but they are not supported by GitHub Pages, so we need to use the `redirect` alias type instead explicitly. We use the new `alias_type` option in the `mike` plugin configuration in the `mkdocs.yml` file to set the alias type to `redirect`. It also avoid failing the documentation publishing job if the `mike` version can't be determined (for example if the branch name is not recognized). It will just emit a warning and skip the publishing. Fixes #173.
2 parents 8bf6c38 + b9e2d84 commit 7e74141

File tree

16 files changed

+64
-13
lines changed

16 files changed

+64
-13
lines changed

RELEASE_NOTES.md

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,57 @@
22

33
## Summary
44

5-
This release fixes a bug in `mike` version sorting.
5+
This release upgrades `mike` to 2.0.0.
66

77
## Upgrading
88

9-
- `frequenz.repo.config.mkdocs.mike.`: The `sort_versions()` function now takes plain `str`s as arguments instead of `MikeVersionInfo` objects.
10-
119
### Cookiecutter template
1210

13-
There is no need to regenerate any templates with this release.
11+
There is no need to re-generate the cookiecutter template for this release. Instead you can upgrade the `mike` package in your `pyproject.toml` file and add the new `alias_type: redirect` option to the `plugins.mike` key in the `mkdocs.yml` file.
12+
13+
You should be able to do this by running the following commands:
14+
15+
```sh
16+
sed -i '/canonical_version: latest/ i\ alias_type: redirect' mkdocs.yml
17+
sed -i 's/ "mike == .*",/ "mike == 2.0.0",/' pyproject.toml
18+
```
19+
20+
Please make sure to check the diff and test if everything works as expected. After doing a `git diff` you should get something like:
21+
22+
```diff
23+
diff --git a/mkdocs.yml b/mkdocs.yml
24+
index 3d0f82e..6adfbe8 100644
25+
--- a/mkdocs.yml
26+
+++ b/mkdocs.yml
27+
@@ -93,6 +93,7 @@ plugins:
28+
- literate-nav:
29+
nav_file: SUMMARY.md
30+
- mike:
31+
+ alias_type: redirect
32+
canonical_version: latest
33+
- mkdocstrings:
34+
custom_templates: templates
35+
diff --git a/pyproject.toml b/pyproject.toml
36+
index 9a1604b..b183524 100644
37+
--- a/pyproject.toml
38+
+++ b/pyproject.toml
39+
@@ -47,7 +47,7 @@ dev-formatting = ["black == 23.10.1", "isort == 5.12.0"]
40+
dev-mkdocs = [
41+
"black == 23.10.1",
42+
"Markdown==3.5.1",
43+
- "mike == 1.1.2",
44+
+ "mike == 2.0.0",
45+
"mkdocs-gen-files == 0.5.0",
46+
"mkdocs-literate-nav == 0.6.1",
47+
"mkdocs-material == 9.4.7",
48+
```
49+
50+
If that's not the case, your `pyproject.toml` and/or `mkdocs.yml` files might have been diverged from the generated files and updated in a way that is not compatible with the upgrade. In that case you'll have to fix it manually or re-generate the templates.
1451

1552
## Bug Fixes
1653

17-
- CI / `mkdocs`: `mike` version sorting now properly sort pre-releases as older than stable releases for the same major and minor version.
54+
- `cli.version.mike.info`: Don't fail if the version can't be determined, just emit a warning and exit succesfully.
55+
56+
### Cookiecutter template
57+
58+
- CI: The documentation publishing job will not fail if the version for `mike` can't be determined, it will just emit a warning and skip the publishing of the documentation website.

cookiecutter/{{cookiecutter.github_repo_name}}/mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ plugins:
9797
- literate-nav:
9898
nav_file: SUMMARY.md
9999
- mike:
100+
alias_type: redirect
100101
canonical_version: latest
101102
- mkdocstrings:
102103
custom_templates: templates

cookiecutter/{{cookiecutter.github_repo_name}}/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ dev-formatting = ["black == 23.9.1", "isort == 5.12.0"]
7171
dev-mkdocs = [
7272
"black == 23.9.1",
7373
"Markdown==3.4.4",
74-
"mike == 1.1.2",
74+
"mike == 2.0.0",
7575
"mkdocs-gen-files == 0.5.0",
7676
"mkdocs-literate-nav == 0.6.1",
7777
"mkdocs-macros-plugin == 1.0.4",

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ plugins:
9393
- literate-nav:
9494
nav_file: SUMMARY.md
9595
- mike:
96+
alias_type: redirect
9697
canonical_version: latest
9798
- mkdocstrings:
9899
custom_templates: templates

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ dev-formatting = ["black == 23.9.1", "isort == 5.12.0"]
7777
dev-mkdocs = [
7878
"black == 23.9.1",
7979
"Markdown==3.4.4",
80-
"mike == 1.1.2",
80+
"mike == 2.0.0",
8181
"mkdocs-gen-files == 0.5.0",
8282
"mkdocs-literate-nav == 0.6.1",
8383
"mkdocs-macros-plugin == 1.0.4",

src/frequenz/repo/config/cli/version/mike/info.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ def main() -> None:
4949
try:
5050
mike_version = mike.build_mike_version(github.get_repo_version_info())
5151
except ValueError as error:
52-
github.abort(f"{error}.", title="Documentation was not published")
52+
gha.warning(
53+
f"{error}.", title="Could not determine the version information for `mike`"
54+
)
55+
return
5356

5457
_output_gha_vars(mike_version)
5558

tests_golden/integration/test_cookiecutter_generation/actor/frequenz-actor-test/mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ plugins:
9797
- literate-nav:
9898
nav_file: SUMMARY.md
9999
- mike:
100+
alias_type: redirect
100101
canonical_version: latest
101102
- mkdocstrings:
102103
custom_templates: templates

tests_golden/integration/test_cookiecutter_generation/actor/frequenz-actor-test/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ dev-formatting = ["black == 23.9.1", "isort == 5.12.0"]
5353
dev-mkdocs = [
5454
"black == 23.9.1",
5555
"Markdown==3.4.4",
56-
"mike == 1.1.2",
56+
"mike == 2.0.0",
5757
"mkdocs-gen-files == 0.5.0",
5858
"mkdocs-literate-nav == 0.6.1",
5959
"mkdocs-macros-plugin == 1.0.4",

tests_golden/integration/test_cookiecutter_generation/api/frequenz-api-test/mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ plugins:
9797
- literate-nav:
9898
nav_file: SUMMARY.md
9999
- mike:
100+
alias_type: redirect
100101
canonical_version: latest
101102
- mkdocstrings:
102103
custom_templates: templates

tests_golden/integration/test_cookiecutter_generation/api/frequenz-api-test/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ dev-formatting = ["black == 23.9.1", "isort == 5.12.0"]
5151
dev-mkdocs = [
5252
"black == 23.9.1",
5353
"Markdown==3.4.4",
54-
"mike == 1.1.2",
54+
"mike == 2.0.0",
5555
"mkdocs-gen-files == 0.5.0",
5656
"mkdocs-literate-nav == 0.6.1",
5757
"mkdocs-macros-plugin == 1.0.4",

0 commit comments

Comments
 (0)