Skip to content

Commit e25acd2

Browse files
committed
workflow: Add a docs workflow
This workflow will build the docs for the zephyr crates for a single particular build, and publish them to GH pages. Signed-off-by: David Brown <[email protected]>
1 parent 83d0bdc commit e25acd2

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

.github/workflows/docs.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Generate and Preview Rust Docs
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main # Only generate docs for PRs targeting main
7+
push:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
17+
jobs:
18+
generate-docs:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
with:
25+
path: zephyr-rust-lang
26+
27+
- name: Set up Python
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: 3.11
31+
32+
- name: Setup Zephyr project
33+
uses: zephyrproject-rtos/action-zephyr-setup@v1
34+
with:
35+
app-path: zephyr-rust-lang
36+
manifest-file-name: ci-manifest.yml
37+
toolchains: arm-zephyr-eabi:riscv64-zephyr-elf
38+
39+
- name: Install Rust Targets
40+
shell: bash
41+
run: |
42+
rustup target add thumbv7em-none-eabi
43+
rustup target add thumbv7m-none-eabi
44+
45+
- name: Setup cargo build
46+
working-directory: zephyr-rust-lang
47+
run: |
48+
# Must do full build
49+
west build -b nrf52840dk/nrf52840 docgen
50+
51+
- name: Build Rust documentation
52+
working-directory: zephyr-rust-lang/docgen
53+
run: |
54+
rm -rf .cargo
55+
mkdir .cargo
56+
cd .cargo
57+
ln -s ../../build/rust/sample-cargo-config.toml config.toml
58+
cd ..
59+
cargo doc
60+
61+
- name: Upload artifact
62+
uses: actions/upload-pages-artifact@v3
63+
with:
64+
path: zephyr-rust-lang/build/rust/target/thumbv7em-none-eabi/doc
65+
66+
# - name: Deploy docs to GitHub Pages for pull requests
67+
# if: github.event_name == 'pull_request'
68+
# uses: peaceiris/actions-gh-pages@v3
69+
# with:
70+
# github_token: ${{ secrets.GITHUB_TOKEN }}
71+
# publish_dir: ./zephyr-rust-lang/build/rust/target/thumbv7em-none-eabi/doc
72+
# publish_branch: gh-pages
73+
# destination_dir: pr-${{ github.event.number }}
74+
75+
# - name: Deploy docs to GitHub Pages for push to main
76+
# if: github.event_name == 'push'
77+
# uses: peaceiris/actions-gh-pages@v3
78+
# with:
79+
# github_token: ${{ secrets.GITHUB_TOKEN }}
80+
# publish_dir: ./target/doc
81+
# publish_branch: gh-pages

0 commit comments

Comments
 (0)