Skip to content

Commit c42ec37

Browse files
ci: use reusable workflows (#388)
1 parent 606188a commit c42ec37

5 files changed

Lines changed: 28 additions & 235 deletions

File tree

.github/workflows/ci.yml

Lines changed: 9 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,43 +10,12 @@ 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
29-
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 --all-targets --locked
38-
39-
- name: Check dependencies
40-
run: cargo deny check
41-
42-
- name: Check unused dependencies
43-
run: cargo machete --with-metadata
44-
45-
- name: Check manifest formatting
46-
run: cargo sort --workspace --check
47-
48-
- name: Check formatting
49-
run: cargo fmt --all --check
13+
rust:
14+
name: Rust
15+
uses: RustForWeb/.github/.github/workflows/rust.yml@c18f3b7315df398b6af8d03f823e31daeda63114
16+
with:
17+
enable-test: false
18+
target: wasm32-unknown-unknown
5019

5120
test:
5221
name: Test
@@ -74,13 +43,13 @@ jobs:
7443

7544
steps:
7645
- name: Checkout
77-
uses: actions/checkout@v6
46+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
7847

7948
- name: Set up Rust toolchain
80-
uses: actions-rust-lang/setup-rust-toolchain@v1
49+
uses: actions-rust-lang/setup-rust-toolchain@2b1f5e9b395427c92ee4e3331786ca3c37afe2d7 # v1.16.0
8150
with:
82-
components: clippy, rustfmt
8351
target: wasm32-unknown-unknown
52+
components: rust-src
8453

8554
- name: Test
8655
run: cargo test --locked --release

.github/workflows/labels.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@ permissions:
88
issues: write
99

1010
jobs:
11-
sync-labels:
12-
name: Sync Labels
13-
runs-on: ubuntu-latest
14-
steps:
15-
- uses: actions/checkout@v6
16-
with:
17-
sparse-checkout: .github/labels.yml
18-
19-
- uses: EndBug/label-sync@v2
20-
with:
21-
config-file: .github/labels.yml
11+
labels:
12+
name: Labels
13+
uses: RustForWeb/.github/.github/workflows/labels.yml@c18f3b7315df398b6af8d03f823e31daeda63114

.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@c18f3b7315df398b6af8d03f823e31daeda63114

.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: getsentry/action-github-app-token@v3
27-
with:
28-
app_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@c18f3b7315df398b6af8d03f823e31daeda63114
22+
with:
23+
bump: ${{ inputs.bump }}

.github/workflows/website.yml

Lines changed: 8 additions & 91 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,100 +8,16 @@ 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
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
57-
run: cargo binstall --force -y mdbook mdbook-tabs
58-
59-
- name: Install Node.js dependencies
60-
run: npm install
61-
62-
- name: Build Book
63-
run: mdbook build
64-
working-directory: book
65-
66-
- name: Upload artifact
67-
uses: actions/upload-artifact@v7
68-
with:
69-
name: book
70-
path: book/book
71-
retention-days: 1
72-
if-no-files-found: error
73-
74-
deploy:
75-
name: Deploy
76-
needs: book-build
77-
if: github.ref == 'refs/heads/main'
78-
runs-on: ubuntu-latest
79-
80-
permissions:
81-
contents: read
82-
pages: write
83-
id-token: write
84-
85-
steps:
86-
- uses: actions/checkout@v6
87-
with:
88-
fetch-depth: 0
89-
90-
- name: Download artifacts
91-
uses: actions/download-artifact@v8
92-
with:
93-
path: dist
94-
merge-multiple: true
95-
96-
- name: Setup Pages
97-
uses: actions/configure-pages@v6
98-
99-
- name: Upload artifact
100-
uses: actions/upload-pages-artifact@v5
101-
with:
102-
path: dist
103-
104-
- name: Deploy to GitHub Pages
105-
id: deployment
106-
uses: actions/deploy-pages@v5
19+
book:
20+
name: Book
21+
uses: RustForWeb/.github/.github/workflows/book.yml@c18f3b7315df398b6af8d03f823e31daeda63114
22+
with:
23+
combine: false

0 commit comments

Comments
 (0)