Skip to content

Commit 1e6cb71

Browse files
committed
chore: improve actions
1 parent fa1331f commit 1e6cb71

1 file changed

Lines changed: 20 additions & 65 deletions

File tree

.github/workflows/build.yml

Lines changed: 20 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,6 @@ jobs:
6262
runs-on: windows-latest
6363
steps:
6464
- uses: actions/checkout@v4
65-
- name: Cache Rust dependencies
66-
uses: actions/cache@v4
67-
with:
68-
path: |
69-
~/.cargo/registry
70-
~/.cargo/git
71-
target
72-
key: windows-cargo-${{ hashFiles('**/Cargo.lock') }}
73-
restore-keys: windows-cargo-
7465

7566
- name: Install Rust stable
7667
uses: dtolnay/rust-toolchain@stable
@@ -104,60 +95,24 @@ jobs:
10495
name: ${{ env.BINARY_NAME }}-windows
10596
path: build/out/*
10697

107-
build-macos-arm:
108-
runs-on: macos-latest
98+
build-macos-slices:
99+
runs-on: ${{ matrix.os }}
100+
strategy:
101+
matrix:
102+
include:
103+
- os: macos-latest
104+
target: aarch64-apple-darwin
105+
arch: arm
106+
- os: macos-15-intel
107+
target: x86_64-apple-darwin
108+
arch: intel
109109
steps:
110110
- uses: actions/checkout@v4
111-
- name: Cache Rust dependencies
112-
uses: actions/cache@v4
113-
with:
114-
path: |
115-
~/.cargo/registry
116-
~/.cargo/git
117-
target
118-
key: macos-arm-cargo-${{ hashFiles('**/Cargo.lock') }}
119-
restore-keys: macos-arm-cargo-
120111

121112
- name: Install Rust stable
122113
uses: dtolnay/rust-toolchain@stable
123114
with:
124-
targets: aarch64-apple-darwin
125-
126-
- name: Build Dependencies
127-
run: |
128-
cargo install patch-crate
129-
cargo fetch --locked || true
130-
cargo patch-crate --force
131-
mkdir -p build/out
132-
133-
- name: Build (macOS ARM)
134-
run: |
135-
cargo build --bin ${{ env.BINARY_NAME }} --release
136-
strip target/release/${{ env.BINARY_NAME }}
137-
cp target/release/${{ env.BINARY_NAME }} build/out/${{ env.BINARY_NAME }}-arm
138-
139-
- name: Upload ARM Slice
140-
uses: actions/upload-artifact@v4
141-
with:
142-
name: ${{ env.BINARY_NAME }}-macos-slice-arm
143-
path: build/out/${{ env.BINARY_NAME }}-arm
144-
145-
build-macos-intel:
146-
runs-on: macos-15-intel
147-
steps:
148-
- uses: actions/checkout@v4
149-
- name: Cache Rust dependencies
150-
uses: actions/cache@v4
151-
with:
152-
path: |
153-
~/.cargo/registry
154-
~/.cargo/git
155-
target
156-
key: macos-intel-cargo-${{ hashFiles('**/Cargo.lock') }}
157-
restore-keys: macos-intel-cargo-
158-
159-
- name: Install Rust stable
160-
uses: dtolnay/rust-toolchain@stable
115+
targets: ${{ matrix.target }}
161116

162117
- name: Build Dependencies
163118
run: |
@@ -166,21 +121,21 @@ jobs:
166121
cargo patch-crate --force
167122
mkdir -p build/out
168123
169-
- name: Build (macOS Intel)
124+
- name: Build (macOS ${{ matrix.arch }})
170125
run: |
171-
cargo build --bin ${{ env.BINARY_NAME }} --release
172-
strip target/release/${{ env.BINARY_NAME }}
173-
cp target/release/${{ env.BINARY_NAME }} build/out/${{ env.BINARY_NAME }}-intel
126+
cargo build --bin ${{ env.BINARY_NAME }} --release --target ${{ matrix.target }}
127+
strip target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}
128+
cp target/${{ matrix.target }}/release/${{ env.BINARY_NAME }} build/out/${{ env.BINARY_NAME }}-${{ matrix.arch }}
174129
175-
- name: Upload Intel Slice
130+
- name: Upload ${{ matrix.arch }} Slice
176131
uses: actions/upload-artifact@v4
177132
with:
178-
name: ${{ env.BINARY_NAME }}-macos-slice-intel
179-
path: build/out/${{ env.BINARY_NAME }}-intel
133+
name: ${{ env.BINARY_NAME }}-macos-slice-${{ matrix.arch }}
134+
path: build/out/${{ env.BINARY_NAME }}-${{ matrix.arch }}
180135

181136
build-macos-universal:
182137
runs-on: macos-latest
183-
needs: [build-macos-arm, build-macos-intel]
138+
needs: [build-macos-slices]
184139
steps:
185140
- uses: actions/checkout@v4
186141

0 commit comments

Comments
 (0)