Skip to content

Commit 99e260d

Browse files
committed
ci: comprehensive workflow improvements
- Fix cargo publish to trigger only on GitHub releases instead of every master commit - Add version verification between release tag and Cargo.toml - Update actions/checkout to @v5 - Replace cargo install with taiki-e/install-action for faster tool installation - Add Swatinem/rust-cache@v2 for faster builds - Add Windows ARM64 native testing (windows-latest-arm) - Add job dependencies to fail fast and save CI minutes Closes: - #994 - #997
1 parent cf422c8 commit 99e260d

2 files changed

Lines changed: 64 additions & 25 deletions

File tree

.github/workflows/cpal.yml

Lines changed: 60 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
name: cpal
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
pull_request:
6+
release:
7+
types: [published]
48

59
jobs:
610

711
clippy-and-fmt:
812
runs-on: ubuntu-latest
913
steps:
10-
- uses: actions/checkout@v4
14+
- uses: actions/checkout@v5
1115
- name: Install Linux audio dependencies
1216
run: |
1317
sudo apt update
@@ -17,6 +21,9 @@ jobs:
1721
with:
1822
components: clippy, rustfmt
1923
targets: armv7-linux-androideabi
24+
25+
- name: Rust Cache
26+
uses: Swatinem/rust-cache@v2
2027
- name: Run rustfmt
2128
run: cargo fmt --all -- --check
2229
- name: Run clippy
@@ -25,26 +32,34 @@ jobs:
2532
run: cargo clippy --all --features asio --target armv7-linux-androideabi
2633

2734
cargo-publish:
28-
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
35+
if: github.event_name == 'release'
36+
needs: [clippy-and-fmt, test-native, test-cross, test-wasm, test-android, test-ios]
2937
runs-on: ubuntu-latest
3038
steps:
31-
- uses: actions/checkout@v4
39+
- uses: actions/checkout@v5
40+
3241
- name: Install Linux audio dependencies
3342
run: |
3443
sudo apt update
3544
sudo apt-get install -y libasound2-dev
45+
3646
- name: Install Rust toolchain
3747
uses: dtolnay/rust-toolchain@stable
38-
- name: Verify publish crate
39-
uses: katyo/publish-crates@v2
40-
with:
41-
dry-run: true
42-
ignore-unpublished-changes: true
43-
- name: Publish crate
44-
uses: katyo/publish-crates@v2
45-
with:
46-
ignore-unpublished-changes: true
47-
registry-token: ${{ secrets.CRATESIO_TOKEN }}
48+
49+
# Verify the release tag matches Cargo.toml version
50+
- name: Verify release version
51+
run: |
52+
CARGO_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
53+
RELEASE_VERSION=${GITHUB_REF#refs/tags/v}
54+
echo "Cargo.toml version: $CARGO_VERSION"
55+
echo "Release tag version: $RELEASE_VERSION"
56+
if [ "$CARGO_VERSION" != "$RELEASE_VERSION" ]; then
57+
echo "Version mismatch! Cargo.toml has $CARGO_VERSION but release tag is v$RELEASE_VERSION"
58+
exit 1
59+
fi
60+
61+
- name: Publish to crates.io
62+
run: cargo publish --token ${{ secrets.CRATESIO_TOKEN }}
4863

4964
# Native platform testing
5065
test-native:
@@ -90,6 +105,18 @@ jobs:
90105
choco install llvm
91106
asio-env: true
92107

108+
# Windows ARM64
109+
- os: windows-latest-arm
110+
name: windows-arm64
111+
target: aarch64-pc-windows-msvc
112+
deps: |
113+
curl -L -o asio.zip https://www.steinberg.net/asiosdk
114+
7z x -oasio asio.zip
115+
move asio\*\* asio\
116+
choco install asio4all
117+
choco install llvm
118+
asio-env: true
119+
93120
# macOS (ARM64 M1/M2)
94121
- os: macOS-latest
95122
name: macos-arm64
@@ -99,7 +126,7 @@ jobs:
99126
runs-on: ${{ matrix.os }}
100127
name: test-${{ matrix.name }}
101128
steps:
102-
- uses: actions/checkout@v4
129+
- uses: actions/checkout@v5
103130

104131
- name: Install dependencies
105132
run: ${{ matrix.deps }}
@@ -109,6 +136,9 @@ jobs:
109136
with:
110137
target: ${{ matrix.target }}
111138

139+
- name: Rust Cache
140+
uses: Swatinem/rust-cache@v2
141+
112142
- name: Build beep example (macOS only)
113143
if: matrix.build-beep
114144
run: cargo build --example beep
@@ -134,15 +164,17 @@ jobs:
134164

135165
name: test-cross-${{ matrix.target }}
136166
steps:
137-
- uses: actions/checkout@v4
167+
- uses: actions/checkout@v5
138168

139169
- name: Install Rust toolchain
140170
uses: dtolnay/rust-toolchain@stable
141171
with:
142172
target: ${{ matrix.target }}
143173

144174
- name: Install cross
145-
run: cargo install cross
175+
uses: taiki-e/install-action@v2
176+
with:
177+
tool: cross
146178

147179
- name: Check without features
148180
run: cross check --target ${{ matrix.target }} --workspace --no-default-features --verbose
@@ -176,7 +208,7 @@ jobs:
176208

177209
name: test-wasm-${{ matrix.target }}
178210
steps:
179-
- uses: actions/checkout@v4
211+
- uses: actions/checkout@v5
180212

181213
- name: Setup Emscripten toolchain
182214
if: matrix.setup-emscripten
@@ -200,7 +232,7 @@ jobs:
200232
test-android:
201233
runs-on: ubuntu-latest
202234
steps:
203-
- uses: actions/checkout@v4
235+
- uses: actions/checkout@v5
204236

205237
- name: Install Rust toolchain (Android targets)
206238
uses: dtolnay/rust-toolchain@stable
@@ -222,8 +254,10 @@ jobs:
222254
run: |
223255
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --sdk_root=$ANDROID_SDK_ROOT --install "build-tools;30.0.2" "platforms;android-30"
224256
225-
- name: Install Cargo APK
226-
run: cargo install cargo-apk
257+
- name: Install cargo-apk
258+
uses: taiki-e/install-action@v2
259+
with:
260+
tool: cargo-apk
227261

228262
- name: Build APK
229263
working-directory: examples/android
@@ -233,7 +267,7 @@ jobs:
233267
test-ios:
234268
runs-on: macOS-latest
235269
steps:
236-
- uses: actions/checkout@v4
270+
- uses: actions/checkout@v5
237271

238272
- name: Install dependencies
239273
run: brew install llvm
@@ -243,8 +277,10 @@ jobs:
243277
with:
244278
targets: aarch64-apple-ios,x86_64-apple-ios
245279

246-
- name: Install cargo lipo
247-
run: cargo install cargo-lipo
280+
- name: Install cargo-lipo
281+
uses: taiki-e/install-action@v2
282+
with:
283+
tool: cargo-lipo
248284

249285
- name: Build iOS example
250286
run: cd examples/ios-feedback && xcodebuild -scheme cpal-ios-example -configuration Debug -derivedDataPath build -sdk iphonesimulator

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
- ALSA: Add `I24` and `U24` sample format support (24-bit samples stored in 4 bytes).
88
- ALSA(process_output): Pass `silent=true` to `PCM.try_recover`, so it doesn't write to stderr.
99
- ASIO: Fix linker flags for MinGW cross-compilation.
10-
- CI: Added native ARM64 Linux support in GitHub Actions.
10+
- CI: Added native ARM64 Linux and Windows support in GitHub Actions.
11+
- CI: Fix cargo publish to trigger on GitHub releases instead of every master commit.
12+
- CI: Replace cargo install commands with cached tool installation for faster builds.
13+
- CI: Update actions to latest versions (checkout@v5, rust-cache@v2).
1114
- CoreAudio: Change `Device::supported_configs` to return a single element containing the available sample rate range when all elements have the same `mMinimum` and `mMaximum` values.
1215
- CoreAudio: Change default audio device detection to be lazy when building a stream, instead of during device enumeration.
1316
- CoreAudio: Add `i8`, `i32` and `I24` sample format support (24-bit samples stored in 4 bytes).

0 commit comments

Comments
 (0)