Skip to content

Commit 5e5ca19

Browse files
committed
chore(github): extract actions from workflows
1 parent 4d5a920 commit 5e5ca19

6 files changed

Lines changed: 77 additions & 88 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Build Rust binary
2+
description: Release build using cross on Linux, cargo elsewhere
3+
4+
inputs:
5+
target:
6+
description: Rust compilation target triple
7+
required: true
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- if: runner.os == 'Linux'
13+
uses: taiki-e/install-action@v2
14+
with:
15+
tool: cross
16+
- if: runner.os == 'Linux'
17+
shell: bash
18+
run: cross build --release --locked --target ${{ inputs.target }}
19+
- if: runner.os != 'Linux'
20+
shell: bash
21+
run: cargo build --release --locked --target ${{ inputs.target }}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Set up Node
2+
description: Install Node.js 24 and update npm to latest
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
8+
with:
9+
node-version: 24
10+
registry-url: "https://registry.npmjs.org"
11+
- shell: bash
12+
run: npm install -g npm@latest
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Set up Rust build
2+
description: Install Rust toolchain with target, cargo cache, and just
3+
4+
inputs:
5+
target:
6+
description: Rust compilation target triple
7+
required: true
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- uses: dtolnay/rust-toolchain@stable
13+
with:
14+
targets: ${{ inputs.target }}
15+
components: rustfmt, clippy
16+
- shell: bash
17+
run: rustup target add ${{ inputs.target }}
18+
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
19+
- uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0
20+
with:
21+
just-version: 1.35.0

.github/workflows/ci.yaml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,10 @@ jobs:
4646
registry-url: "https://registry.npmjs.org"
4747
- name: Install pnpm
4848
run: npm install -g pnpm@11.1.2
49-
- name: Install rust toolchain
50-
uses: dtolnay/rust-toolchain@stable
49+
- name: Set up Rust build
50+
uses: ./.github/actions/setup-rust-build
5151
with:
52-
targets: ${{ matrix.build.TARGET }}
53-
components: rustfmt, clippy
54-
- name: Set up cargo cache
55-
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
56-
- name: Install just
57-
uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0
58-
with:
59-
just-version: 1.35.0
52+
target: ${{ matrix.build.TARGET }}
6053
- name: Check cargo
6154
run: just check-cargo
6255
- name: Lint formatting

.github/workflows/release.yaml

Lines changed: 10 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -43,40 +43,16 @@ jobs:
4343
echo "matrix.build.TARGET : ${{ matrix.build.TARGET }}"
4444
- name: Checkout
4545
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
46-
- name: Install node
47-
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
46+
- name: Set up Node
47+
uses: ./.github/actions/setup-node
48+
- name: Set up Rust build
49+
uses: ./.github/actions/setup-rust-build
4850
with:
49-
node-version: 24
50-
registry-url: "https://registry.npmjs.org"
51-
- name: Update npm
52-
run: npm install -g npm@latest
53-
- name: Install rust toolchain
54-
uses: dtolnay/rust-toolchain@stable
51+
target: ${{ matrix.build.TARGET }}
52+
- name: Build Rust binary
53+
uses: ./.github/actions/build-rust-binary
5554
with:
56-
targets: ${{ matrix.build.TARGET }}
57-
components: rustfmt, clippy
58-
- name: Add target to active toolchain
59-
shell: bash
60-
run: rustup target add ${{ matrix.build.TARGET }}
61-
- name: Set up cargo cache
62-
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
63-
- name: Install just
64-
uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0
65-
with:
66-
just-version: 1.35.0
67-
- name: Install cross
68-
if: ${{ matrix.build.OS == 'ubuntu-latest' }}
69-
uses: taiki-e/install-action@v2
70-
with:
71-
tool: cross
72-
- name: Build rust binary (cross)
73-
if: ${{ matrix.build.OS == 'ubuntu-latest' }}
74-
shell: bash
75-
run: cross build --release --locked --target ${{ matrix.build.TARGET }}
76-
- name: Build rust binary (cargo)
77-
if: ${{ matrix.build.OS != 'ubuntu-latest' }}
78-
shell: bash
79-
run: cargo build --release --locked --target ${{ matrix.build.TARGET }}
55+
target: ${{ matrix.build.TARGET }}
8056
- name: Publish rust binary package to npm
8157
shell: bash
8258
run: |
@@ -95,13 +71,8 @@ jobs:
9571
steps:
9672
- name: Checkout
9773
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
98-
- name: Install node
99-
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
100-
with:
101-
node-version: 24
102-
registry-url: "https://registry.npmjs.org"
103-
- name: Update npm
104-
run: npm install -g npm@latest
74+
- name: Set up Node
75+
uses: ./.github/actions/setup-node
10576
- name: Install just
10677
uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0
10778
with:

.github/workflows/test-release.yaml

Lines changed: 10 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -40,40 +40,16 @@ jobs:
4040
echo "matrix.build.TARGET : ${{ matrix.build.TARGET }}"
4141
- name: Checkout
4242
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
43-
- name: Install node
44-
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
43+
- name: Set up Node
44+
uses: ./.github/actions/setup-node
45+
- name: Set up Rust build
46+
uses: ./.github/actions/setup-rust-build
4547
with:
46-
node-version: 24
47-
registry-url: "https://registry.npmjs.org"
48-
- name: Update npm
49-
run: npm install -g npm@latest
50-
- name: Install rust toolchain
51-
uses: dtolnay/rust-toolchain@stable
48+
target: ${{ matrix.build.TARGET }}
49+
- name: Build Rust binary
50+
uses: ./.github/actions/build-rust-binary
5251
with:
53-
targets: ${{ matrix.build.TARGET }}
54-
components: rustfmt, clippy
55-
- name: Add target to active toolchain
56-
shell: bash
57-
run: rustup target add ${{ matrix.build.TARGET }}
58-
- name: Set up cargo cache
59-
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
60-
- name: Install just
61-
uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0
62-
with:
63-
just-version: 1.35.0
64-
- name: Install cross
65-
if: ${{ matrix.build.OS == 'ubuntu-latest' }}
66-
uses: taiki-e/install-action@v2
67-
with:
68-
tool: cross
69-
- name: Build rust binary (cross)
70-
if: ${{ matrix.build.OS == 'ubuntu-latest' }}
71-
shell: bash
72-
run: cross build --release --locked --target ${{ matrix.build.TARGET }}
73-
- name: Build rust binary (cargo)
74-
if: ${{ matrix.build.OS != 'ubuntu-latest' }}
75-
shell: bash
76-
run: cargo build --release --locked --target ${{ matrix.build.TARGET }}
52+
target: ${{ matrix.build.TARGET }}
7753
- name: (Test) Publish rust binary package to npm
7854
shell: bash
7955
run: |
@@ -86,13 +62,8 @@ jobs:
8662
steps:
8763
- name: Checkout
8864
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
89-
- name: Install node
90-
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
91-
with:
92-
node-version: 24
93-
registry-url: "https://registry.npmjs.org"
94-
- name: Update npm
95-
run: npm install -g npm@latest
65+
- name: Set up Node
66+
uses: ./.github/actions/setup-node
9667
- name: Install just
9768
uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0
9869
with:

0 commit comments

Comments
 (0)