|
| 1 | +name: Deploy Documentation |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - ci/deploy-docs |
| 7 | + - master |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
| 14 | +env: |
| 15 | + RUST_BACKTRACE: 1 |
| 16 | + |
| 17 | +jobs: |
| 18 | + build-docs: |
| 19 | + strategy: |
| 20 | + matrix: |
| 21 | + include: |
| 22 | + - os: ubuntu-latest |
| 23 | + target: x86_64-unknown-linux-gnu |
| 24 | + artifact-name: docs-linux |
| 25 | + - os: windows-latest |
| 26 | + target: x86_64-pc-windows-msvc |
| 27 | + artifact-name: docs-windows |
| 28 | + - os: macos-latest |
| 29 | + target: aarch64-apple-darwin |
| 30 | + artifact-name: docs-darwin |
| 31 | + runs-on: ${{ matrix.os }} |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v4 |
| 34 | + |
| 35 | + - name: Setup Rust Toolchain |
| 36 | + run: | |
| 37 | + rustup toolchain install nightly |
| 38 | + rustup default nightly |
| 39 | + rustup target add ${{ matrix.target }} |
| 40 | +
|
| 41 | + - name: Build Documentation for ${{ matrix.target }} |
| 42 | + shell: bash |
| 43 | + run: | |
| 44 | + GIT_SHA=$(git rev-parse --short HEAD) |
| 45 | + export RUSTDOCFLAGS="-Zunstable-options --enable-index-page --cfg docsrs --crate-version $GIT_SHA" |
| 46 | + cargo doc --workspace --no-deps --all-features --target ${{ matrix.target }} |
| 47 | +
|
| 48 | + - name: Prepare documentation artifact |
| 49 | + shell: bash |
| 50 | + run: | |
| 51 | + mkdir -p docs-output/${{ matrix.target }} |
| 52 | + cp -r target/${{ matrix.target }}/doc/* docs-output/${{ matrix.target }}/ |
| 53 | +
|
| 54 | + - name: Upload documentation artifact |
| 55 | + uses: actions/upload-artifact@v4 |
| 56 | + with: |
| 57 | + name: ${{ matrix.artifact-name }} |
| 58 | + path: docs-output/${{ matrix.target }} |
| 59 | + retention-days: 1 |
| 60 | + |
| 61 | + deploy: |
| 62 | + needs: build-docs |
| 63 | + runs-on: ubuntu-latest |
| 64 | + permissions: |
| 65 | + contents: read |
| 66 | + deployments: write |
| 67 | + steps: |
| 68 | + - uses: actions/checkout@v4 |
| 69 | + |
| 70 | + - name: Download Linux docs |
| 71 | + uses: actions/download-artifact@v4 |
| 72 | + with: |
| 73 | + name: docs-linux |
| 74 | + path: public/x86_64-unknown-linux-gnu |
| 75 | + |
| 76 | + - name: Download Windows docs |
| 77 | + uses: actions/download-artifact@v4 |
| 78 | + with: |
| 79 | + name: docs-windows |
| 80 | + path: public/x86_64-pc-windows-msvc |
| 81 | + |
| 82 | + - name: Download Darwin docs |
| 83 | + uses: actions/download-artifact@v4 |
| 84 | + with: |
| 85 | + name: docs-darwin |
| 86 | + path: public/aarch64-apple-darwin |
| 87 | + |
| 88 | + - name: Copy index page |
| 89 | + run: | |
| 90 | + cp docs/index.html public/index.html |
| 91 | +
|
| 92 | + - name: Deploy to Cloudflare Pages |
| 93 | + uses: cloudflare/wrangler-action@v3 |
| 94 | + with: |
| 95 | + apiToken: ${{ secrets.CF_API_TOKEN }} |
| 96 | + accountId: ${{ secrets.CF_ACCOUNT_ID }} |
| 97 | + command: deploy --assets public --name compio-docs --compatibility-date 2026-01-23 |
0 commit comments