Skip to content

Commit 8ad0cc6

Browse files
CopilotMR-Addict
andauthored
Update to mdbook 0.5.x compatibility (#19)
* Initial plan * Update mdbook dependency from 0.4.x to 0.5.x Co-authored-by: MR-Addict <75357598+MR-Addict@users.noreply.github.com> * Update imports to use mdbook-preprocessor and mdbook-core 0.5.x APIs Co-authored-by: MR-Addict <75357598+MR-Addict@users.noreply.github.com> * Fix CLI to properly handle supports subcommand Co-authored-by: MR-Addict <75357598+MR-Addict@users.noreply.github.com> * Remove unnecessary lifetime parameters from get_config_string Co-authored-by: MR-Addict <75357598+MR-Addict@users.noreply.github.com> * Fix CI workflows to extract mdbook version from mdbook-core dependency Co-authored-by: MR-Addict <75357598+MR-Addict@users.noreply.github.com> * Fix CI workflows to check and reinstall mdbook if version mismatches Co-authored-by: MR-Addict <75357598+MR-Addict@users.noreply.github.com> * Fix test book.toml preprocessor path to use correct relative path Co-authored-by: MR-Addict <75357598+MR-Addict@users.noreply.github.com> * Fix mdbook compatibility by updating book.toml and modifying scroll-to-top button SVG * refactor: remove raw type for mdbook, setup mdbook installation in workflows and update documentation for include app * Fix paths for setup actions in workflows to ensure correct execution * fix: update output setting for version retrieval in release workflow --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: MR-Addict <75357598+MR-Addict@users.noreply.github.com> Co-authored-by: Cael <MR-Addict@qq.com>
1 parent d219500 commit 8ad0cc6

20 files changed

Lines changed: 484 additions & 2333 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: "Install mdbook"
2+
description: "Install mdbook based on Cargo.toml version"
3+
4+
runs:
5+
using: "composite"
6+
steps:
7+
- name: Install mdbook
8+
run: |
9+
REQUIRED_VERSION="$(grep '^mdbook-core' Cargo.toml | sed 's/.*"\([^"]*\)".*/\1/')"
10+
if command -v mdbook >/dev/null 2>&1; then
11+
INSTALLED_VERSION="$(mdbook --version | awk '{print $2}')"
12+
if [ "$INSTALLED_VERSION" = "$REQUIRED_VERSION" ]; then
13+
echo "mdbook $INSTALLED_VERSION is already installed."
14+
else
15+
echo "mdbook $INSTALLED_VERSION is installed but we need $REQUIRED_VERSION. Reinstalling..."
16+
cargo install mdbook --version "$REQUIRED_VERSION" --force
17+
fi
18+
else
19+
echo "mdbook not found. Installing version $REQUIRED_VERSION..."
20+
cargo install mdbook --version "$REQUIRED_VERSION" --force
21+
fi
22+
shell: bash

.github/workflows/page.yaml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,13 @@ jobs:
1818
uses: ./.github/actions/setup-rust
1919

2020
- name: Install mdbook
21-
run: |
22-
if ! command -v mdbook >/dev/null 2>&1; then
23-
cargo install mdbook --version "$(grep '^mdbook' Cargo.toml | sed 's/.*"\([^"]*\)".*/\1/')" --force
24-
else
25-
echo "mdbook is already installed, skipping."
26-
fi
21+
uses: ./.github/actions/setup-mdbook
2722

2823
- name: Run tests
2924
run: cargo test --all-features --verbose
3025

3126
- name: Build book
32-
run: mdbook build docs
27+
run: head -n 5 README.md > docs/src/index.md && mdbook build docs
3328

3429
- name: Deploy to github pages
3530
uses: crazy-max/ghaction-github-pages@v4

.github/workflows/release.yaml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,7 @@ jobs:
1414
uses: ./.github/actions/setup-rust
1515

1616
- name: Install mdbook
17-
run: |
18-
if ! command -v mdbook >/dev/null 2>&1; then
19-
cargo install mdbook --version "$(grep '^mdbook' Cargo.toml | sed 's/.*"\([^"]*\)".*/\1/')" --force
20-
else
21-
echo "mdbook is already installed, skipping."
22-
fi
17+
uses: ./.github/actions/setup-mdbook
2318

2419
- name: Run tests
2520
run: cargo test --all-features --verbose
@@ -74,7 +69,7 @@ jobs:
7469

7570
- name: Get the version
7671
id: get_version
77-
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
72+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
7873

7974
- name: Install packages
8075
run: sudo apt update && sudo apt install -y upx-ucl zip

0 commit comments

Comments
 (0)