Skip to content

Commit 567d20c

Browse files
committed
task: Update CI workflows
1 parent 9cdb5a7 commit 567d20c

2 files changed

Lines changed: 65 additions & 71 deletions

File tree

.github/workflows/ci.yml

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,27 @@ on:
77
# branches: [ main, master ]
88

99
jobs:
10-
test-crates:
11-
name: Build & Test crates
10+
test:
11+
name: Build & Test workspace
1212
runs-on: ubuntu-latest
13-
strategy:
14-
matrix:
15-
crate: [ "i2c", "emmc_spi" ]
16-
rust: [ "stable" ]
17-
1813
steps:
1914
- name: Checkout
20-
uses: actions/checkout@v4
15+
uses: actions/checkout@v7
16+
17+
- name: Install Rust
18+
uses: dtolnay/rust-toolchain@stable
2119

2220
- name: Cache cargo registry and target
23-
uses: actions/cache@v4
21+
uses: actions/cache@v6
2422
with:
2523
path: |
2624
~/.cargo/registry
2725
~/.cargo/git
28-
${{ matrix.crate }}/target
29-
key: ${{ runner.os }}-cargo-${{ matrix.crate }}-${{ hashFiles('**/Cargo.lock') }}
30-
31-
- name: Setup Rust toolchain
32-
uses: actions-rs/toolchain@v1
33-
with:
34-
toolchain: ${{ matrix.rust }}
35-
components: clippy, rustfmt
26+
target
27+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
3628

3729
- name: Build (release)
38-
run: cargo build --manifest-path ${{ matrix.crate }}/Cargo.toml --release --verbose
30+
run: cargo build --workspace --release --all-features --verbose
3931

4032
- name: Run tests
41-
run: cargo test --manifest-path ${{ matrix.crate }}/Cargo.toml --verbose --all-features
42-
43-
- name: Upload built artifacts
44-
uses: actions/upload-artifact@v4
45-
with:
46-
name: ${{ matrix.crate }}-release
47-
path: ${{ matrix.crate }}/target/release
33+
run: cargo test --workspace --all-features --verbose

.github/workflows/release.yml

Lines changed: 54 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -7,82 +7,90 @@ on:
77

88
jobs:
99
build:
10-
name: Build on ${{ matrix.os }}
10+
name: ${{ matrix.target }}
1111
runs-on: ${{ matrix.os }}
1212
strategy:
13+
fail-fast: false
1314
matrix:
14-
os: [ ubuntu-latest, macos-latest, windows-latest ]
15-
crate: [ aspect2-stm32-updater, soundchip-cli ]
15+
target:
16+
- x86_64-pc-windows-msvc
17+
- aarch64-pc-windows-msvc
18+
- x86_64-unknown-linux-gnu
19+
- aarch64-unknown-linux-gnu
20+
- x86_64-apple-darwin
21+
- aarch64-apple-darwin
22+
include:
23+
- target: x86_64-pc-windows-msvc
24+
os: windows-latest
25+
- target: aarch64-pc-windows-msvc
26+
os: windows-latest
27+
- target: x86_64-unknown-linux-gnu
28+
os: ubuntu-latest
29+
- target: aarch64-unknown-linux-gnu
30+
os: ubuntu-latest
31+
- target: x86_64-apple-darwin
32+
os: macos-latest
33+
- target: aarch64-apple-darwin
34+
os: macos-latest
1635

1736
steps:
1837
- name: Checkout
19-
uses: actions/checkout@v6
38+
uses: actions/checkout@v7
39+
40+
- name: Install Rust
41+
uses: dtolnay/rust-toolchain@stable
42+
with:
43+
targets: ${{ matrix.target }}
2044

2145
- name: Cache cargo registry and target
22-
uses: actions/cache@v4
46+
uses: actions/cache@v6
2347
with:
2448
path: |
2549
~/.cargo/registry
2650
~/.cargo/git
27-
${{ matrix.crate }}/target
28-
key: ${{ runner.os }}-cargo-${{ matrix.crate }}-${{ hashFiles('**/Cargo.lock') }}
29-
30-
- name: Setup Rust
31-
uses: actions-rs/toolchain@v1
32-
with:
33-
toolchain: stable
34-
35-
- name: Build crate
36-
run: cargo build --manifest-path ${{ matrix.crate }}/Cargo.toml --release --verbose
51+
target
52+
key: ${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
3753

38-
- name: Package artifacts (non-Windows)
39-
if: runner.os != 'Windows'
54+
- name: Install aarch64 linker
55+
if: matrix.target == 'aarch64-unknown-linux-gnu'
4056
run: |
41-
mkdir -p release_artifacts
42-
cp ${{ matrix.crate }}/target/release/${{ matrix.crate }} release_artifacts/${{ matrix.crate }}-${{ matrix.os }} || true
43-
zip -r release-${{ matrix.crate }}-${{ matrix.os }}.zip release_artifacts
44-
sha256sum release-${{ matrix.crate }}-${{ matrix.os }}.zip | awk '{print $1}' > release-${{ matrix.crate }}-${{ matrix.os }}.sha256
57+
sudo apt-get update
58+
sudo apt-get install -y gcc-aarch64-linux-gnu
59+
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> "$GITHUB_ENV"
4560
46-
- name: Package artifacts (Windows)
47-
if: runner.os == 'Windows'
48-
shell: pwsh
61+
- name: Build workspace
62+
run: cargo build --workspace --release --all-features --target ${{ matrix.target }} --verbose
63+
64+
- name: Stage binaries
65+
shell: bash
4966
run: |
50-
New-Item -ItemType Directory -Path release_artifacts -Force | Out-Null
51-
$exe = "${{ matrix.crate }}.exe"
52-
$src = Join-Path -Path (Join-Path -Path "${{ matrix.crate }}" -ChildPath "target\release") -ChildPath $exe
53-
$dst = "release_artifacts\${{ matrix.crate }}-${{ matrix.os }}.exe"
54-
Copy-Item -Path $src -Destination $dst -ErrorAction SilentlyContinue
55-
$zipname = "release-${{ matrix.crate }}-${{ matrix.os }}.zip"
56-
Compress-Archive -Path release_artifacts/* -DestinationPath $zipname -Force
57-
(Get-FileHash $zipname -Algorithm SHA256).Hash | Out-File -Encoding ascii ("${zipname}.sha256")
67+
ext=""
68+
[[ "${{ matrix.target }}" == *windows* ]] && ext=".exe"
69+
mkdir dist
70+
for bin in aspect2-stm32-updater postcode_emu soundchip_cli flash_cli i2c_scan; do
71+
cp "target/${{ matrix.target }}/release/${bin}${ext}" "dist/${bin}-${{ matrix.target }}${ext}"
72+
done
5873
59-
- name: Upload per-OS release artifact
60-
uses: actions/upload-artifact@v4
74+
- name: Upload artifacts
75+
uses: actions/upload-artifact@v7
6176
with:
62-
name: release-${{ matrix.crate }}-${{ matrix.os }}
63-
path: |
64-
release-${{ matrix.crate }}-${{ matrix.os }}.zip
65-
release-${{ matrix.crate }}-${{ matrix.os }}.sha256
77+
name: ${{ matrix.target }}
78+
path: dist/*
6679

6780
create_release:
6881
if: startsWith(github.ref, 'refs/tags/')
6982
name: Create GitHub Release
7083
runs-on: ubuntu-latest
7184
needs: build
7285
steps:
73-
- name: Checkout
74-
uses: actions/checkout@v4
75-
7686
- name: Download build artifacts
77-
uses: actions/download-artifact@v4
87+
uses: actions/download-artifact@v8
7888
with:
7989
path: release_artifacts_all
80-
81-
- name: List downloaded artifacts
82-
run: ls -la release_artifacts_all
90+
merge-multiple: true
8391

8492
- name: Create GitHub Release and upload artifacts
85-
uses: softprops/action-gh-release@v1
93+
uses: softprops/action-gh-release@v3
8694
with:
8795
files: release_artifacts_all/*
8896
env:

0 commit comments

Comments
 (0)