diff --git a/.github/workflows/book.yml b/.github/workflows/website.yml similarity index 67% rename from .github/workflows/book.yml rename to .github/workflows/website.yml index 7cd9473..379f690 100644 --- a/.github/workflows/book.yml +++ b/.github/workflows/website.yml @@ -1,4 +1,4 @@ -name: Book +name: Website on: pull_request: {} push: @@ -10,8 +10,8 @@ concurrency: cancel-in-progress: false jobs: - test: - name: Test + book-test: + name: Test Book runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -27,13 +27,11 @@ jobs: cache-on-failure: true save-if: ${{ github.ref == 'refs/heads/main' }} - - name: Install latest mdbook - run: | - tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name') - url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz" - mkdir bin - curl -sSL $url | tar -xz --directory=bin - echo "$(pwd)/bin" >> $GITHUB_PATH + - name: Install Cargo Binary Install + uses: cargo-bins/cargo-binstall@main + + - name: Install mdBook + run: cargo binstall -y mdbook - name: Install mdBook plugins run: cargo install mdbook-tabs mdbook-trunk @@ -42,15 +40,10 @@ jobs: run: mdbook test working-directory: book - deploy: - name: Deploy - needs: test - if: github.ref == 'refs/heads/main' + book-build: + name: Build Book + needs: book-test runs-on: ubuntu-latest - permissions: - contents: read - pages: write - id-token: write steps: - uses: actions/checkout@v4 with: @@ -67,16 +60,11 @@ jobs: cache-on-failure: true save-if: ${{ github.ref == 'refs/heads/main' }} - - name: Install Trunk - run: cargo install trunk + - name: Install Cargo Binary Install + uses: cargo-bins/cargo-binstall@main - - name: Install latest mdbook - run: | - tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name') - url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz" - mkdir mdbook - curl -sSL $url | tar -xz --directory=./mdbook - echo `pwd`/mdbook >> $GITHUB_PATH + - name: Install mdBook and Trunk + run: cargo binstall -y mdbook trunk - name: Install mdBook plugins run: cargo install mdbook-tabs mdbook-trunk @@ -92,13 +80,41 @@ jobs: run: mdbook-trunk combine working-directory: book + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: book + path: book/dist + retention-days: 1 + if-no-files-found: error + + deploy: + name: Deploy + needs: book-build + if: github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + permissions: + contents: read + pages: write + id-token: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Download artifcats + uses: actions/download-artifact@v4 + with: + path: dist + merge-multiple: true + - name: Setup Pages uses: actions/configure-pages@v4 - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: - path: 'book/dist' + path: dist - name: Deploy to GitHub Pages id: deployment