update workflow with correct target definitio, add cli
Build and Release Firmware / firmware (ak4490) (push) Successful in 14s
Build and Release Firmware / firmware (cs4398) (push) Successful in 13s
Build and Release Firmware / firmware (evk) (push) Successful in 13s
Build and Release Firmware / cli (aarch64-unknown-linux-musl) (push) Successful in 1m12s
Build and Release Firmware / cli (x86_64-unknown-linux-musl) (push) Canceled after 0s
Build and Release Firmware / release (push) Canceled after 0s
Build and Release Firmware / cli (x86_64-pc-windows-gnu) (push) Canceled after 55s
Build and Release Firmware / firmware (ak4490) (push) Successful in 14s
Build and Release Firmware / firmware (cs4398) (push) Successful in 13s
Build and Release Firmware / firmware (evk) (push) Successful in 13s
Build and Release Firmware / cli (aarch64-unknown-linux-musl) (push) Successful in 1m12s
Build and Release Firmware / cli (x86_64-unknown-linux-musl) (push) Canceled after 0s
Build and Release Firmware / release (push) Canceled after 0s
Build and Release Firmware / cli (x86_64-pc-windows-gnu) (push) Canceled after 55s
This commit is contained in:
1 parent
e255636f3a
commit
5b6cd11ac3
1 file changed
+117
-34
+117
-34
@@ -7,60 +7,143 @@ on:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
TARGET: thumbv8m.main-none-eabihf
|
TARGET: thumbv8m.main-none-eabihf
|
||||||
|
# The catthehacker image installs rust here and only symlinks ~/.rustup and ~/.cargo to it.
|
||||||
|
# actions/cache archives the symlink, not its contents, so point at the real paths.
|
||||||
|
RUSTUP_HOME: /usr/share/rust/.rustup
|
||||||
|
CARGO_HOME: /usr/share/rust/.cargo
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-release:
|
firmware:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: catthehacker/ubuntu:act-latest
|
image: catthehacker/ubuntu:rust-latest
|
||||||
defaults:
|
strategy:
|
||||||
run:
|
fail-fast: true
|
||||||
shell: bash
|
matrix:
|
||||||
|
variant: [cs4398, ak4490, evk]
|
||||||
|
env:
|
||||||
|
FEATURES: ${{ matrix.variant }},hid
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Cache rustup
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ${{ env.RUSTUP_HOME }}
|
||||||
|
key: rustup-firmware-${{ env.TARGET }}-${{ runner.os }}
|
||||||
|
|
||||||
- name: Install Rust Toolchain
|
- name: Install Rust Toolchain
|
||||||
uses: dtolnay/rust-toolchain@stable
|
|
||||||
- name: Install cargo-binutils
|
|
||||||
run: cargo install cargo-binutils
|
|
||||||
- name: Build Firmware Binaries
|
|
||||||
run: |
|
run: |
|
||||||
cd firmware
|
rustup target install ${{ env.TARGET }}
|
||||||
|
rustup component add llvm-tools
|
||||||
|
|
||||||
# Array of "variant_name:features"
|
- name: Cache cargo
|
||||||
VARIANTS=(
|
uses: Swatinem/rust-cache@v2
|
||||||
"cs4398:cs4398,hid"
|
with:
|
||||||
"ak4490:ak4490,hid"
|
shared-key: firmware-${{ matrix.variant }}
|
||||||
"evk:evk,hid"
|
|
||||||
)
|
|
||||||
|
|
||||||
mkdir -p ../dist
|
- name: Install cargo-binutils
|
||||||
|
run: cargo binstall -y --locked cargo-binutils
|
||||||
|
|
||||||
for entry in "${VARIANTS[@]}"; do
|
- name: Build firmware (${{ matrix.variant }})
|
||||||
IFS=":" read -r name features <<< "$entry"
|
working-directory: firmware
|
||||||
echo "Building variant: $name with features: $features"
|
run: cargo build --release --target ${{ env.TARGET }} --no-default-features --features "${{ env.FEATURES }}"
|
||||||
|
|
||||||
# 1. Compile release binary
|
- name: Create hex file
|
||||||
cargo build --release --target ${{ env.TARGET }} --no-default-features --features "$features"
|
working-directory: firmware
|
||||||
|
run: cargo objcopy --release --target ${{ env.TARGET }} --no-default-features --features "${{ env.FEATURES }}" -- -O ihex ../target/${{ env.TARGET }}/release/guac-${{ matrix.variant }}.hex
|
||||||
|
|
||||||
# 2. Paths setup
|
- name: Package
|
||||||
ELF_PATH="../target/${{ env.TARGET }}/release/guac"
|
run: |
|
||||||
HEX_PATH="../target/${{ env.TARGET }}/release/guac-${name}.hex"
|
out=target/${{ env.TARGET }}/release
|
||||||
RENAMED_ELF="../target/${{ env.TARGET }}/release/guac-${name}.elf"
|
cp "$out/guac" "$out/guac-${{ matrix.variant }}.elf"
|
||||||
|
mkdir -p dist
|
||||||
|
zip -j "dist/guac-firmware-${{ matrix.variant }}.zip" "$out/guac-${{ matrix.variant }}.elf" "$out/guac-${{ matrix.variant }}.hex"
|
||||||
|
|
||||||
# 3. Create .hex file via rust-objcopy
|
- name: Upload artifact
|
||||||
cargo objcopy --release --target ${{ env.TARGET }} --no-default-features --features "$features" -- -O ihex "$HEX_PATH"
|
uses: actions/upload-artifact@v3
|
||||||
cp "$ELF_PATH" "$RENAMED_ELF"
|
with:
|
||||||
|
name: firmware-${{ matrix.variant }}
|
||||||
|
path: dist/*.zip
|
||||||
|
|
||||||
# 4. Package ELF and HEX into target-specific ZIP
|
cli:
|
||||||
ZIP_NAME="guac-firmware-${name}.zip"
|
runs-on: ubuntu-latest
|
||||||
zip -j "../dist/${ZIP_NAME}" "$RENAMED_ELF" "$HEX_PATH"
|
container:
|
||||||
done
|
image: catthehacker/ubuntu:rust-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: true
|
||||||
|
matrix:
|
||||||
|
target:
|
||||||
|
- aarch64-unknown-linux-musl
|
||||||
|
- x86_64-pc-windows-gnu
|
||||||
|
- x86_64-unknown-linux-musl
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Cache rustup
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ${{ env.RUSTUP_HOME }}
|
||||||
|
key: rustup-cli-${{ matrix.target }}-${{ runner.os }}
|
||||||
|
|
||||||
|
- name: Install Rust Toolchain
|
||||||
|
run: rustup target install ${{ matrix.target }}
|
||||||
|
|
||||||
|
- name: Cache cargo
|
||||||
|
uses: Swatinem/rust-cache@v2
|
||||||
|
with:
|
||||||
|
shared-key: cli-${{ matrix.target }}
|
||||||
|
|
||||||
|
- name: Cache zig toolchain
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
/opt/zigvenv
|
||||||
|
~/.cache/zig
|
||||||
|
~/.cache/cargo-zigbuild
|
||||||
|
key: zigbuild-${{ matrix.target }}-${{ runner.os }}
|
||||||
|
|
||||||
|
- name: Install cargo-zigbuild Toolchain
|
||||||
|
run: |
|
||||||
|
# venv keeps cargo-zigbuild and ziglang in one relocatable-by-path directory we can cache
|
||||||
|
[ -d /opt/zigvenv ] || python3 -m venv /opt/zigvenv
|
||||||
|
/opt/zigvenv/bin/pip install cargo-zigbuild
|
||||||
|
echo /opt/zigvenv/bin >> "$GITHUB_PATH"
|
||||||
|
|
||||||
|
- name: Build cli (${{ matrix.target }})
|
||||||
|
working-directory: cli
|
||||||
|
run: cargo zigbuild --release --target ${{ matrix.target }}
|
||||||
|
|
||||||
|
- name: Package
|
||||||
|
run: |
|
||||||
|
bin=cli
|
||||||
|
[[ "${{ matrix.target }}" == *windows* ]] && bin=cli.exe
|
||||||
|
mkdir -p dist
|
||||||
|
zip -j "dist/guac-cli-${{ matrix.target }}.zip" "target/${{ matrix.target }}/release/$bin"
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Upload artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: cli-${{ matrix.target }}
|
||||||
|
path: dist/*.zip
|
||||||
|
|
||||||
|
release:
|
||||||
|
needs: [firmware, cli]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: catthehacker/ubuntu:act-latest
|
||||||
|
steps:
|
||||||
|
- name: Download artifacts
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
path: dist
|
||||||
|
|
||||||
- name: Create Gitea Release
|
- name: Create Gitea Release
|
||||||
uses: akkuman/gitea-release-action@v1
|
uses: akkuman/gitea-release-action@v1
|
||||||
with:
|
with:
|
||||||
files: dist/*.zip
|
files: dist/**/*.zip
|
||||||
draft: false
|
draft: false
|
||||||
prerelease: false
|
prerelease: false
|
||||||
Reference in new issue
Block a user