Skip to content

Commit 2d4237e

Browse files
ci: use reusable workflows (#320)
1 parent 052dad8 commit 2d4237e

7 files changed

Lines changed: 31 additions & 237 deletions

File tree

.github/workflows/ci.yml

Lines changed: 15 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -10,78 +10,48 @@ permissions:
1010
contents: read
1111

1212
jobs:
13-
lint:
14-
name: Lint
15-
runs-on: ubuntu-latest
16-
17-
env:
18-
RUSTFLAGS: '-Dwarnings'
19-
20-
steps:
21-
- name: Checkout
22-
uses: actions/checkout@v6
23-
24-
- name: Set up Rust toolchain
25-
uses: actions-rust-lang/setup-rust-toolchain@v1
26-
with:
27-
components: clippy, rustfmt
28-
target: wasm32-unknown-unknown
13+
rust:
14+
name: Rust
15+
uses: RustForWeb/.github/.github/workflows/rust.yml@373c25f8fd29e10c40f1343f13312f8be3514af0
16+
with:
17+
enable-test: false
18+
target: wasm32-unknown-unknown
2919

30-
- name: Install Cargo Binary Install
31-
uses: cargo-bins/cargo-binstall@main
32-
33-
- name: Install crates
34-
run: cargo binstall -y --force cargo-deny cargo-machete cargo-sort
35-
36-
- name: Lint
37-
run: cargo clippy --all-features --locked
38-
39-
- name: Check dependencies
40-
run: cargo deny check
41-
42-
- name: Check unused dependencies
43-
run: cargo machete
44-
45-
- name: Check manifest formatting
46-
run: cargo sort --workspace --check
47-
48-
- name: Check formatting
49-
run: cargo fmt --all --check
5020
test:
5121
name: Test
5222
runs-on: ubuntu-latest
5323

5424
steps:
5525
- name: Checkout
56-
uses: actions/checkout@v6
26+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
5727

5828
- name: Set up Rust toolchain
59-
uses: actions-rust-lang/setup-rust-toolchain@v1
29+
uses: actions-rust-lang/setup-rust-toolchain@2b1f5e9b395427c92ee4e3331786ca3c37afe2d7 # v1.16.0
6030
with:
61-
components: clippy, rustfmt
6231
target: wasm32-unknown-unknown
32+
components: rust-src
6333

6434
- name: Install Cargo Binary Install
65-
uses: cargo-bins/cargo-binstall@main
35+
uses: cargo-bins/cargo-binstall@dc19f1e48450eefe5a29b8da6c6b00a87d730b37 # v1.18.1
6636

67-
- name: Install Trunk
68-
run: cargo binstall --force -y trunk
37+
- name: Install crates
38+
run: cargo binstall -y --force trunk
6939

7040
- name: Set up Node.js
71-
uses: actions/setup-node@v6
41+
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
7242
with:
7343
node-version: 'lts/*'
7444

7545
- name: Set up pnpm
76-
uses: pnpm/action-setup@v5
46+
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0
7747
with:
7848
version: 'latest'
7949

8050
- name: Test
8151
run: cargo test --all-features --locked --release
8252

8353
- name: Upload visual snapshot diffs
84-
uses: actions/upload-artifact@v7
54+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
8555
if: always()
8656
with:
8757
name: visual-snapshots-diff

.github/workflows/publish.yml

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,11 @@ on:
44
release:
55
types: [published]
66

7+
permissions:
8+
contents: read
9+
id-token: write
10+
711
jobs:
812
publish:
913
name: Publish
10-
runs-on: ubuntu-latest
11-
12-
permissions:
13-
contents: read
14-
id-token: write
15-
16-
steps:
17-
- name: Checkout
18-
uses: actions/checkout@v6
19-
20-
- name: Set up Rust toolchain
21-
uses: actions-rust-lang/setup-rust-toolchain@v1
22-
with:
23-
target: wasm32-unknown-unknown
24-
25-
- name: Install Cargo Binary Install
26-
uses: cargo-bins/cargo-binstall@main
27-
28-
- name: Install crates
29-
run: cargo binstall --force -y cargo-workspaces
30-
31-
- uses: rust-lang/crates-io-auth-action@v1
32-
id: auth
33-
34-
- name: Publish
35-
run: cargo workspaces publish --publish-as-is
36-
env:
37-
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
14+
uses: RustForWeb/.github/.github/workflows/publish.yml@373c25f8fd29e10c40f1343f13312f8be3514af0

.github/workflows/release.yml

Lines changed: 3 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -18,68 +18,6 @@ permissions:
1818
jobs:
1919
release:
2020
name: Release
21-
runs-on: ubuntu-latest
22-
23-
steps:
24-
- name: Generate GitHub App token
25-
id: app-token
26-
uses: actions/create-github-app-token@v3
27-
with:
28-
client-id: ${{ secrets.APP_ID }}
29-
private-key: ${{ secrets.APP_PRIVATE_KEY }}
30-
31-
- name: Checkout
32-
uses: actions/checkout@v6
33-
34-
- name: Set up Rust toolchain
35-
uses: actions-rust-lang/setup-rust-toolchain@v1
36-
with:
37-
target: wasm32-unknown-unknown
38-
39-
- name: Install Cargo Binary Install
40-
uses: cargo-bins/cargo-binstall@main
41-
42-
- name: Install crates
43-
run: cargo binstall --force -y cargo-workspaces toml-cli
44-
45-
- name: Bump version
46-
run: cargo workspaces version --all --no-git-commit --yes ${{ inputs.bump }}
47-
48-
- name: Extract version
49-
id: extract-version
50-
run: echo "VERSION=v$(toml get Cargo.toml workspace.package.version --raw)" >> "$GITHUB_OUTPUT"
51-
52-
- name: Add changes
53-
run: git add .
54-
55-
- name: Commit
56-
id: commit
57-
uses: dsanders11/github-app-commit-action@v2
58-
with:
59-
message: ${{ steps.extract-version.outputs.VERSION }}
60-
token: ${{ steps.app-token.outputs.token }}
61-
62-
- name: Reset and pull
63-
run: git reset --hard && git pull
64-
65-
- name: Tag
66-
uses: actions/github-script@v9
67-
env:
68-
GIT_TAG: ${{ steps.extract-version.outputs.VERSION }}
69-
GIT_SHA: ${{ steps.commit.outputs.sha }}
70-
with:
71-
script: |
72-
github.rest.git.createRef({
73-
owner: context.repo.owner,
74-
repo: context.repo.repo,
75-
ref: `refs/tags/${process.env.GIT_TAG}`,
76-
sha: process.env.GIT_SHA
77-
})
78-
79-
- name: Release
80-
uses: softprops/action-gh-release@v3
81-
with:
82-
generate_release_notes: true
83-
make_latest: true
84-
tag_name: ${{ steps.extract-version.outputs.VERSION }}
85-
token: ${{ steps.app-token.outputs.token }}
21+
uses: RustForWeb/.github/.github/workflows/release.yml@373c25f8fd29e10c40f1343f13312f8be3514af0
22+
with:
23+
bump: ${{ inputs.bump }}

.github/workflows/website.yml

Lines changed: 6 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: Website
2+
23
on:
34
pull_request: {}
45
push:
@@ -7,104 +8,14 @@ on:
78

89
permissions:
910
contents: read
11+
id-token: write
12+
pages: write
1013

1114
concurrency:
1215
group: ${{ github.workflow }}-${{ github.ref }}
1316
cancel-in-progress: false
1417

1518
jobs:
16-
book-test:
17-
name: Test Book
18-
runs-on: ubuntu-latest
19-
20-
steps:
21-
- uses: actions/checkout@v6
22-
23-
- name: Set up Rust toolchain
24-
uses: actions-rust-lang/setup-rust-toolchain@v1
25-
with:
26-
target: wasm32-unknown-unknown
27-
28-
- name: Install Cargo Binary Install
29-
uses: cargo-bins/cargo-binstall@main
30-
31-
- name: Install mdBook
32-
run: cargo binstall --force -y mdbook mdbook-tabs mdbook-trunk
33-
34-
- name: Run tests
35-
run: mdbook test
36-
working-directory: book
37-
38-
book-build:
39-
name: Build Book
40-
needs: book-test
41-
runs-on: ubuntu-latest
42-
43-
steps:
44-
- uses: actions/checkout@v6
45-
with:
46-
fetch-depth: 0
47-
48-
- name: Set up Rust toolchain
49-
uses: actions-rust-lang/setup-rust-toolchain@v1
50-
with:
51-
target: wasm32-unknown-unknown
52-
53-
- name: Install Cargo Binary Install
54-
uses: cargo-bins/cargo-binstall@main
55-
56-
- name: Install mdBook and Trunk
57-
run: cargo binstall --force -y mdbook mdbook-tabs mdbook-trunk trunk
58-
59-
- name: Install Node.js dependencies
60-
run: npm ci
61-
62-
- name: Build Book
63-
run: mdbook build
64-
working-directory: book
65-
66-
- name: Combine Book Outputs
67-
run: mdbook-trunk combine
68-
working-directory: book
69-
70-
- name: Upload artifact
71-
uses: actions/upload-artifact@v7
72-
with:
73-
name: book
74-
path: book/dist
75-
retention-days: 1
76-
if-no-files-found: error
77-
78-
deploy:
79-
name: Deploy
80-
needs: book-build
81-
if: github.ref == 'refs/heads/main'
82-
runs-on: ubuntu-latest
83-
84-
permissions:
85-
contents: read
86-
pages: write
87-
id-token: write
88-
89-
steps:
90-
- uses: actions/checkout@v6
91-
with:
92-
fetch-depth: 0
93-
94-
- name: Download artifacts
95-
uses: actions/download-artifact@v8
96-
with:
97-
path: dist
98-
merge-multiple: true
99-
100-
- name: Setup Pages
101-
uses: actions/configure-pages@v6
102-
103-
- name: Upload artifact
104-
uses: actions/upload-pages-artifact@v5
105-
with:
106-
path: dist
107-
108-
- name: Deploy to GitHub Pages
109-
id: deployment
110-
uses: actions/deploy-pages@v5
19+
book:
20+
name: Book
21+
uses: RustForWeb/.github/.github/workflows/book.yml@373c25f8fd29e10c40f1343f13312f8be3514af0

Cargo.lock

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/dioxus/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ floating-ui-dom.workspace = true
1515
web-sys.workspace = true
1616

1717
[dev-dependencies]
18-
wasm-bindgen-test.workspace = true
18+
# wasm-bindgen-test.workspace = true

packages/yew/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ web-sys.workspace = true
1515
yew.workspace = true
1616

1717
[dev-dependencies]
18-
wasm-bindgen-test.workspace = true
18+
# wasm-bindgen-test.workspace = true

0 commit comments

Comments
 (0)