Skip to content

Commit 49f31d2

Browse files
ci: use reusable workflows
1 parent b5a0bc7 commit 49f31d2

3 files changed

Lines changed: 23 additions & 248 deletions

File tree

.github/workflows/publish.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
contents: read
9+
id-token: write
10+
11+
jobs:
12+
publish:
13+
name: Publish
14+
uses: RustForWeb/.github/.github/workflows/publish.yml@373c25f8fd29e10c40f1343f13312f8be3514af0

.github/workflows/release.yml

Lines changed: 3 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -18,159 +18,6 @@ permissions:
1818
jobs:
1919
release:
2020
name: Release
21-
runs-on: ubuntu-latest
22-
23-
outputs:
24-
version: ${{ steps.extract-version.outputs.VERSION }}
25-
26-
steps:
27-
- name: Generate GitHub App token
28-
id: app-token
29-
uses: getsentry/action-github-app-token@v3
30-
with:
31-
app_id: ${{ secrets.APP_ID }}
32-
private_key: ${{ secrets.APP_PRIVATE_KEY }}
33-
34-
- name: Checkout
35-
uses: actions/checkout@v6
36-
37-
- name: Set up Rust toolchain
38-
uses: actions-rust-lang/setup-rust-toolchain@v1
39-
with:
40-
target: wasm32-unknown-unknown
41-
42-
- name: Install Cargo Binary Install
43-
uses: cargo-bins/cargo-binstall@main
44-
45-
- name: Install crates
46-
run: cargo binstall --force -y cargo-workspaces toml-cli
47-
48-
- name: Bump version
49-
run: cargo workspaces version --all --no-git-commit --yes ${{ inputs.bump }}
50-
51-
- name: Extract version
52-
id: extract-version
53-
run: echo "VERSION=v$(toml get Cargo.toml workspace.package.version --raw)" >> "$GITHUB_OUTPUT"
54-
55-
- name: Add changes
56-
run: git add .
57-
58-
- name: Commit
59-
uses: dsanders11/github-app-commit-action@v2
60-
with:
61-
message: ${{ steps.extract-version.outputs.VERSION }}
62-
token: ${{ steps.app-token.outputs.token }}
63-
64-
- name: Reset and pull
65-
run: git reset --hard && git pull
66-
67-
- name: Tag
68-
uses: bruno-fs/repo-tagger@1.0.0
69-
with:
70-
tag: ${{ steps.extract-version.outputs.VERSION }}
71-
env:
72-
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
73-
74-
- name: Release
75-
uses: softprops/action-gh-release@v3
76-
with:
77-
generate_release_notes: true
78-
make_latest: true
79-
tag_name: ${{ steps.extract-version.outputs.VERSION }}
80-
token: ${{ steps.app-token.outputs.token }}
81-
82-
- name: Publish
83-
run: cargo workspaces publish --publish-as-is --token "${{ secrets.CRATES_IO_TOKEN }}"
84-
85-
release-binary:
86-
strategy:
87-
fail-fast: false
88-
matrix:
89-
package: [mdbook-tabs, mdbook-trunk]
90-
target:
91-
[
92-
aarch64-unknown-linux-gnu,
93-
aarch64-unknown-linux-musl,
94-
x86_64-unknown-linux-gnu,
95-
x86_64-unknown-linux-musl,
96-
aarch64-apple-darwin,
97-
x86_64-apple-darwin,
98-
x86_64-pc-windows-msvc,
99-
]
100-
include:
101-
- target: aarch64-unknown-linux-gnu
102-
os: ubuntu-latest
103-
- target: aarch64-unknown-linux-musl
104-
os: ubuntu-latest
105-
- target: x86_64-unknown-linux-gnu
106-
os: ubuntu-latest
107-
- target: x86_64-unknown-linux-musl
108-
os: ubuntu-latest
109-
- target: aarch64-apple-darwin
110-
os: macos-latest
111-
- target: x86_64-apple-darwin
112-
os: macos-latest
113-
- target: x86_64-pc-windows-msvc
114-
os: windows-latest
115-
116-
runs-on: ${{ matrix.os }}
117-
name: Release ${{ matrix.package }} for ${{ matrix.target }}
118-
needs: release
119-
120-
steps:
121-
- uses: actions/checkout@v6
122-
123-
- name: Set up Rust toolchain
124-
uses: actions-rust-lang/setup-rust-toolchain@v1
125-
with:
126-
components: clippy, llvm-tools-preview, rustfmt, rust-std
127-
target: ${{ matrix.target }}
128-
129-
- name: Set up target (*-musl)
130-
if: ${{ endsWith(matrix.target, '-musl') }}
131-
run: |
132-
sudo apt update -y
133-
sudo apt install -y musl-dev musl-tools
134-
135-
- name: Set up target (aarch64-unknown-linux-gnu)
136-
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
137-
run: |
138-
sudo apt update -y
139-
sudo apt install -y gcc-aarch64-linux-gnu
140-
echo CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc >> $GITHUB_ENV
141-
142-
- name: Set up target (aarch64-unknown-linux-musl)
143-
if: ${{ matrix.target == 'aarch64-unknown-linux-musl' }}
144-
run: |
145-
sudo apt update -y
146-
sudo apt install -y clang llvm musl-dev musl-tools
147-
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS=-Clink-self-contained=yes -Clinker=rust-lld" >> $GITHUB_ENV
148-
echo CC_aarch64_unknown_linux_musl=clang >> $GITHUB_ENV
149-
echo AR_aarch64_unknown_linux_musl=llvm-ar >> $GITHUB_ENV
150-
151-
- name: Build
152-
run: cargo build --bins --locked --release --target ${{ matrix.target }}
153-
154-
- name: Archive (tar.gz)
155-
if: ${{ !contains(matrix.target, '-windows-') }}
156-
run: tar czf ../../${{ matrix.package }}-${{ needs.release.outputs.version }}-${{ matrix.target }}.tar.gz ${{ matrix.package }}
157-
working-directory: target/${{ matrix.target }}/release
158-
159-
- name: Archive (zip)
160-
if: ${{ contains(matrix.target, '-windows-') }}
161-
run: 7z a ../../${{ matrix.package }}-${{ needs.release.outputs.version }}-${{ matrix.target }}.zip ${{ matrix.package }}.exe
162-
working-directory: target/${{ matrix.target }}/release
163-
164-
- name: Upload release asset (tar.gz)
165-
if: ${{ !contains(matrix.target, '-windows-') }}
166-
uses: softprops/action-gh-release@v3
167-
with:
168-
tag_name: ${{ needs.release.outputs.version }}
169-
files: target/${{ matrix.package }}-${{ needs.release.outputs.version }}-${{ matrix.target }}.tar.gz
170-
171-
- name: Upload release asset (zip)
172-
if: ${{ contains(matrix.target, '-windows-') }}
173-
uses: softprops/action-gh-release@v3
174-
with:
175-
tag_name: ${{ needs.release.outputs.version }}
176-
files: target/${{ matrix.package }}-${{ needs.release.outputs.version }}-${{ matrix.target }}.zip
21+
uses: RustForWeb/.github/.github/workflows/release.yml@373c25f8fd29e10c40f1343f13312f8be3514af0
22+
with:
23+
bump: ${{ inputs.bump }}

.github/workflows/website.yml

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

0 commit comments

Comments
 (0)