-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Publish
bevy_lint
docs to Github Pages (#160)
Closes #155, extracted from #152. While refactoring I moved `extract-rust-version` to a separate, callable workflow that can be used by both `ci.yml` and `docs.yml`.
- Loading branch information
Showing
3 changed files
with
117 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: Docs | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
workflow_dispatch: | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
# Only allow one deployment to run at a time, however do not cancel runs in progress. | ||
concurrency: | ||
group: pages | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
extract-rust-version: | ||
uses: ./.github/workflows/extract-rust-version.yml | ||
|
||
build-lint-docs: | ||
name: Build `bevy_lint` docs | ||
runs-on: ubuntu-latest | ||
needs: extract-rust-version | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Rust | ||
uses: dtolnay/rust-toolchain@master | ||
with: | ||
toolchain: ${{ needs.extract-rust-version.outputs.channel }} | ||
components: ${{ needs.extract-rust-version.outputs.components }} | ||
|
||
- name: Cache build artifacts | ||
uses: Leafwing-Studios/cargo-cache@v2 | ||
with: | ||
sweep-cache: true | ||
|
||
- name: Build with `rustdoc` | ||
# We don't need to document dependencies since this is not intended to be consumed as a | ||
# library. Furthermore, we pass `--lib` to prevent it from documenting binaries | ||
# automatically. | ||
run: cargo doc --package bevy_lint --no-deps --lib | ||
|
||
- name: Finalize documentation | ||
run: | | ||
# Redirect root `index.html` to `bevy_lint/index.html`. | ||
echo '<meta http-equiv="refresh" content="0; url=bevy_lint/index.html">' > target/doc/index.html | ||
# Sometimes Github Pages fails to bundle and publish `rustdoc` websites due to the weird | ||
# permissions of this file. Remove it, just in case. | ||
rm --force target/doc/.lock | ||
- name: Upload pages artifact | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
path: target/doc | ||
|
||
deploy: | ||
name: Deploy docs | ||
runs-on: ubuntu-latest | ||
needs: build-lint-docs | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deploy.outputs.page_url }} | ||
# These are the permissions required to deploy websites to Github Pages. | ||
permissions: | ||
pages: write | ||
id-token: write | ||
steps: | ||
- name: Deploy to Github Pages | ||
id: deploy | ||
uses: actions/deploy-pages@v4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Find the nightly Rust version and required components in `rust-toolchain.toml` using | ||
# <https://taplo.tamasfe.dev>. The output of this workflow can then be used in | ||
# `@dtolnay/rust-toolchain` to install Rust. | ||
|
||
name: Extract Rust Version | ||
|
||
on: | ||
workflow_call: | ||
outputs: | ||
channel: | ||
description: The Rustup channel extracted from `rust-toolchain.toml`. | ||
value: ${{ jobs.extract-rust-version.outputs.channel }} | ||
components: | ||
description: A comma-separated list of Rustup components extracted from `rust-toolchain.toml`. | ||
value: ${{ jobs.extract-rust-version.outputs.components }} | ||
|
||
jobs: | ||
extract-rust-version: | ||
name: Extract Rust version | ||
runs-on: ubuntu-latest | ||
outputs: | ||
channel: ${{ steps.toolchain.outputs.channel }} | ||
components: ${{ steps.toolchain.outputs.components }} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Taplo | ||
run: | | ||
curl -fsSL https://github.com/tamasfe/taplo/releases/latest/download/taplo-linux-x86_64.gz \ | ||
| gzip -d - | install -m 755 /dev/stdin /usr/local/bin/taplo | ||
- name: Extract toolchain | ||
id: toolchain | ||
run: | | ||
CHANNEL=$(taplo get -f='rust-toolchain.toml' 'toolchain.channel') | ||
COMPONENTS=$(taplo get -f='rust-toolchain.toml' --separator=', ' 'toolchain.components') | ||
echo channel=$CHANNEL >> $GITHUB_OUTPUT | ||
echo components=$COMPONENTS >> $GITHUB_OUTPUT |