Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish bevy_lint docs to Github Pages #160

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 4 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,12 @@ on:
pull_request:
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

jobs:
# Find the nightly Rust version and required components from `rust-toolchain.toml` using
# <https://taplo.tamasfe.dev>, so that we install can install them in later jobs.
extract-rust-version:
name: Extract Rust version
runs-on: ubuntu-latest
outputs:
channel: ${{ steps.toolchain.outputs.toolchain }}
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: |
TOOLCHAIN=$(taplo get -f='rust-toolchain.toml' 'toolchain.channel')
COMPONENTS=$(taplo get -f='rust-toolchain.toml' --separator=', ' 'toolchain.components')

echo toolchain=$TOOLCHAIN >> $GITHUB_OUTPUT
echo components=$COMPONENTS >> $GITHUB_OUTPUT
uses: ./.github/workflows/extract-rust-version.yml

test:
name: Run tests
Expand Down
73 changes: 73 additions & 0 deletions .github/workflows/docs.yml
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
40 changes: 40 additions & 0 deletions .github/workflows/extract-rust-version.yml
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
Loading