-
-
Notifications
You must be signed in to change notification settings - Fork 83
79 lines (71 loc) · 2.28 KB
/
docs-retro.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Retroactive Documentation Deployment
on:
workflow_dispatch: # Allows manual triggering of the workflow
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Get the entire history so all tags are available
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- name: Cache Dependencies
uses: actions/cache@v4
with:
path: ~/.cargo
key: cargo-cache-${{ hashFiles('**/Cargo.lock') }}
- name: Install dependencies
run: |
cargo install mdbook mdbook-mermaid mdbook-toc
- name: Generate and Deploy Documentation
run: |
mkdir -p deploy
tags=$(git tag -l 'v*') # Assumes tag format is v<version>
latest_version=""
for tag in $tags; do
git checkout $tag
version=${tag#v}
if [[ "$version" > "$latest_version" ]]; then
latest_version=$version
fi
deploy_dir="deploy/$version"
if [[ ! -d $deploy_dir ]]; then
if [[ -d "docs" ]]; then
cd docs
mdbook build
mv book ../$deploy_dir
cd ..
else
echo "Docs folder not found for tag $tag."
fi
else
echo "Documentation already exists for tag $tag."
fi
done
git checkout main # Return to main branch before deployment
# Build and move the latest version documentation to root directory
git checkout "v$latest_version"
if [[ -d "docs" ]]; then
cd docs
mdbook build
mv book ../deploy_latest
cd ..
else
echo "Docs folder not found for the latest tag v$latest_version."
fi
- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: deploy
single-commit: true
- name: Deploy Latest Documentation
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: deploy_latest
target-folder: .
single-commit: true