diff --git a/.github/workflows/rustdoc.yml b/.github/workflows/rustdoc.yml new file mode 100644 index 00000000000..159cbcf3b98 --- /dev/null +++ b/.github/workflows/rustdoc.yml @@ -0,0 +1,78 @@ +name: Publish rustdoc + +on: + push: + branches: + - master + +# This will cancel previous runs when a branch or PR is updated +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref || github.run_id }} + cancel-in-progress: true + +jobs: + build: + name: Build + runs-on: ubuntu-22.04 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Rust + uses: dtolnay/rust-toolchain@1.85.0 + + - name: Configure cache + uses: Swatinem/rust-cache@v2 + + - name: Setup pages + id: pages + uses: actions/configure-pages@v5 + + - name: Clean docs folder + run: cargo clean --doc + + - name: Build docs + run: cargo doc --no-deps --document-private-items --workspace + + - name: Add redirect + run: echo '' > target/doc/index.html + + - name: Remove lock file + run: rm target/doc/.lock + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: rustdoc + path: target/doc + + deploy: + name: Deploy + runs-on: ubuntu-22.04 + needs: build + steps: + - uses: actions/checkout@v4 + with: + ref: gh-pages + + - name: Clear old docs + run: rm -rf ./docs + + - name: Download rustdoc output + uses: actions/download-artifact@v4 + with: + name: rustdoc + path: ./docs + + - name: Configure git + run: | + git config --global user.name "rustdoc" + git config --global user.email "github@users.noreply.github.com" + + - name: Commit new docs + run: | + # This could _potentially_ clash with pushing benchmarks to this branch at the same time. + # In practice, this will complete much sooner than the benchmarks are generated. + git add ./docs/* + git commit -m "update rustdoc" + git push \ No newline at end of file