Skip to content

Commit 5e2b9e9

Browse files
authored
chore: add workflow to publish rustdoc to github pages (#7687)
1 parent 4f67909 commit 5e2b9e9

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

.github/workflows/rustdoc.yml

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Publish rustdoc
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
# This will cancel previous runs when a branch or PR is updated
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref || github.run_id }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
build:
15+
name: Build
16+
runs-on: ubuntu-22.04
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Rust
22+
uses: dtolnay/rust-toolchain@1.85.0
23+
24+
- name: Configure cache
25+
uses: Swatinem/rust-cache@v2
26+
27+
- name: Setup pages
28+
id: pages
29+
uses: actions/configure-pages@v5
30+
31+
- name: Clean docs folder
32+
run: cargo clean --doc
33+
34+
- name: Build docs
35+
run: cargo doc --no-deps --document-private-items --workspace
36+
37+
- name: Add redirect
38+
run: echo '<meta http-equiv="refresh" content="0;url=nargo/index.html">' > target/doc/index.html
39+
40+
- name: Remove lock file
41+
run: rm target/doc/.lock
42+
43+
- name: Upload artifact
44+
uses: actions/upload-artifact@v4
45+
with:
46+
name: rustdoc
47+
path: target/doc
48+
49+
deploy:
50+
name: Deploy
51+
runs-on: ubuntu-22.04
52+
needs: build
53+
steps:
54+
- uses: actions/checkout@v4
55+
with:
56+
ref: gh-pages
57+
58+
- name: Clear old docs
59+
run: rm -rf ./docs
60+
61+
- name: Download rustdoc output
62+
uses: actions/download-artifact@v4
63+
with:
64+
name: rustdoc
65+
path: ./docs
66+
67+
- name: Configure git
68+
run: |
69+
git config --global user.name "rustdoc"
70+
git config --global user.email "github@users.noreply.github.com"
71+
72+
- name: Commit new docs
73+
run: |
74+
# This could _potentially_ clash with pushing benchmarks to this branch at the same time.
75+
# In practice, this will complete much sooner than the benchmarks are generated.
76+
git add ./docs/*
77+
git commit -m "update rustdoc"
78+
git push

0 commit comments

Comments
 (0)