Skip to content

Commit a674502

Browse files
committed
chore: fix version parsing in docs pipeline
1 parent 167b7bf commit a674502

1 file changed

Lines changed: 21 additions & 11 deletions

File tree

.github/workflows/docs.yml

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,35 @@ jobs:
3737
3838
- name: Install mdBook and plugins
3939
run: |
40-
# Check if tools are already installed and up to date
41-
install_if_missing() {
40+
# Check if tools are installed with correct major.minor version
41+
install_if_needed() {
4242
local tool=$1
43-
local version=$2
44-
if ! command -v $tool &> /dev/null || ! $tool --version | grep -q "$version"; then
45-
cargo install $tool --vers "$version" --locked
43+
local major_minor=$2
44+
local cargo_version=$3
45+
46+
if command -v $tool &> /dev/null; then
47+
local current_version=$($tool --version | grep -oE 'v[0-9]+\.[0-9]+' | head -1)
48+
if [[ "$current_version" =~ v$major_minor ]]; then
49+
echo "$tool $current_version already installed and compatible, skipping"
50+
return
51+
else
52+
echo "$tool $current_version found but incompatible, updating to $cargo_version"
53+
fi
4654
else
47-
echo "$tool $version already installed, skipping"
55+
echo "Installing $tool $cargo_version"
4856
fi
57+
58+
cargo install $tool --vers "$cargo_version" --locked --force
4959
}
5060
5161
# Install mdBook with optimizations
52-
install_if_missing mdbook "^0.4"
62+
install_if_needed mdbook "0\.4" "^0.4"
5363
5464
# Install plugins
55-
install_if_missing mdbook-admonish "^1.18"
56-
install_if_missing mdbook-mermaid "^0.14"
57-
install_if_missing mdbook-toc "^0.14"
58-
install_if_missing mdbook-katex "^0.9"
65+
install_if_needed mdbook-admonish "1\." "^1.18"
66+
install_if_needed mdbook-mermaid "0\.14" "^0.14"
67+
install_if_needed mdbook-toc "0\.14" "^0.14"
68+
install_if_needed mdbook-katex "0\.9" "^0.9"
5969
# Note: linkcheck skipped due to issues with LaTeX math syntax
6070
6171
- name: Cache mdBook build

0 commit comments

Comments
 (0)