Skip to content

Commit a1d2d0b

Browse files
Update website workflow
1 parent 6575997 commit a1d2d0b

1 file changed

Lines changed: 44 additions & 28 deletions

File tree

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Book
1+
name: Website
22
on:
33
pull_request: {}
44
push:
@@ -10,8 +10,8 @@ concurrency:
1010
cancel-in-progress: false
1111

1212
jobs:
13-
test:
14-
name: Test
13+
book-test:
14+
name: Test Book
1515
runs-on: ubuntu-latest
1616
steps:
1717
- uses: actions/checkout@v4
@@ -27,13 +27,11 @@ jobs:
2727
cache-on-failure: true
2828
save-if: ${{ github.ref == 'refs/heads/main' }}
2929

30-
- name: Install latest mdbook
31-
run: |
32-
tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name')
33-
url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz"
34-
mkdir bin
35-
curl -sSL $url | tar -xz --directory=bin
36-
echo "$(pwd)/bin" >> $GITHUB_PATH
30+
- name: Install Cargo Binary Install
31+
uses: cargo-bins/cargo-binstall@main
32+
33+
- name: Install mdBook
34+
run: cargo binstall -y mdbook
3735

3836
- name: Install mdBook plugins
3937
run: cargo install mdbook-tabs mdbook-trunk
@@ -42,15 +40,10 @@ jobs:
4240
run: mdbook test
4341
working-directory: book
4442

45-
deploy:
46-
name: Deploy
47-
needs: test
48-
if: github.ref == 'refs/heads/main'
43+
book-build:
44+
name: Build Book
45+
needs: book-test
4946
runs-on: ubuntu-latest
50-
permissions:
51-
contents: read
52-
pages: write
53-
id-token: write
5447
steps:
5548
- uses: actions/checkout@v4
5649
with:
@@ -67,16 +60,11 @@ jobs:
6760
cache-on-failure: true
6861
save-if: ${{ github.ref == 'refs/heads/main' }}
6962

70-
- name: Install Trunk
71-
run: cargo install trunk
63+
- name: Install Cargo Binary Install
64+
uses: cargo-bins/cargo-binstall@main
7265

73-
- name: Install latest mdbook
74-
run: |
75-
tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name')
76-
url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz"
77-
mkdir mdbook
78-
curl -sSL $url | tar -xz --directory=./mdbook
79-
echo `pwd`/mdbook >> $GITHUB_PATH
66+
- name: Install mdBook and Trunk
67+
run: cargo binstall -y mdbook trunk
8068

8169
- name: Install mdBook plugins
8270
run: cargo install mdbook-tabs mdbook-trunk
@@ -92,13 +80,41 @@ jobs:
9280
run: mdbook-trunk combine
9381
working-directory: book
9482

83+
- name: Upload artifact
84+
uses: actions/upload-artifact@v4
85+
with:
86+
name: book
87+
path: book/dist
88+
retention-days: 1
89+
if-no-files-found: error
90+
91+
deploy:
92+
name: Deploy
93+
needs: book-build
94+
if: github.ref == 'refs/heads/main'
95+
runs-on: ubuntu-latest
96+
permissions:
97+
contents: read
98+
pages: write
99+
id-token: write
100+
steps:
101+
- uses: actions/checkout@v4
102+
with:
103+
fetch-depth: 0
104+
105+
- name: Download artifcats
106+
uses: actions/download-artifact@v4
107+
with:
108+
path: dist
109+
merge-multiple: true
110+
95111
- name: Setup Pages
96112
uses: actions/configure-pages@v4
97113

98114
- name: Upload artifact
99115
uses: actions/upload-pages-artifact@v3
100116
with:
101-
path: 'book/dist'
117+
path: dist
102118

103119
- name: Deploy to GitHub Pages
104120
id: deployment

0 commit comments

Comments
 (0)