Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc92b55df4
|
No files matched your search
@@ -0,0 +1,31 @@
|
|||||||
|
FROM ghcr.io/rust-cross/cargo-zigbuild:latest
|
||||||
|
|
||||||
|
# The base image may resolve its toolchain through $HOME, which the runner does not preserve for
|
||||||
|
# action containers, so pin it to a fixed path. entrypoint.sh re-exports this because the runner
|
||||||
|
# injects the workflow environment into action containers as well.
|
||||||
|
ENV RUSTUP_HOME=/usr/local/rustup
|
||||||
|
|
||||||
|
RUN if ! rustup default >/dev/null 2>&1; then \
|
||||||
|
rustup toolchain install stable --profile minimal --no-self-update; \
|
||||||
|
rustup default stable; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# The image ships the toolchain, zig, a macOS SDK and cargo-zigbuild, but not the bits the build and
|
||||||
|
# packaging scripts need.
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends ca-certificates zip zstd \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Install every target up front so building needs no network access. `universal2-apple-darwin` is
|
||||||
|
# not a rustc target: cargo-zigbuild builds both architectures and merges them.
|
||||||
|
RUN rustup target install \
|
||||||
|
aarch64-unknown-linux-musl \
|
||||||
|
x86_64-unknown-linux-musl \
|
||||||
|
x86_64-pc-windows-gnu \
|
||||||
|
aarch64-apple-darwin \
|
||||||
|
x86_64-apple-darwin
|
||||||
|
|
||||||
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|
||||||
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
name: Build guac CLI
|
||||||
|
description: Cross-compile the guac CLI with cargo-zigbuild and package the artifact
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
target:
|
||||||
|
description: Rust target triple, or universal2-apple-darwin
|
||||||
|
required: true
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: docker
|
||||||
|
image: Dockerfile
|
||||||
|
args:
|
||||||
|
- ${{ inputs.target }}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
target="$1"
|
||||||
|
|
||||||
|
cd "${GITHUB_WORKSPACE:-$(pwd)}"
|
||||||
|
|
||||||
|
# The runner overrides env vars from the workflow for action containers, so re-assert the
|
||||||
|
# toolchain path the image installed to, and keep the registry in the workspace for caching.
|
||||||
|
export RUSTUP_HOME=/usr/local/rustup
|
||||||
|
export CARGO_HOME="${PWD}/.cargo-cache"
|
||||||
|
|
||||||
|
bin=guac-cli
|
||||||
|
case "$target" in
|
||||||
|
*windows*) bin=guac-cli.exe ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
(cd cli && cargo zigbuild --release --target "$target")
|
||||||
|
|
||||||
|
artifact="target/${target}/release/${bin}"
|
||||||
|
if [ ! -f "$artifact" ]; then
|
||||||
|
artifact="cli/${artifact}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p dist
|
||||||
|
zip -j "dist/guac-cli-${target}.zip" "$artifact"
|
||||||
@@ -5,13 +5,6 @@ on:
|
|||||||
tags:
|
tags:
|
||||||
- "v*"
|
- "v*"
|
||||||
|
|
||||||
env:
|
|
||||||
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:
|
||||||
firmware:
|
firmware:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -21,8 +14,15 @@ jobs:
|
|||||||
fail-fast: true
|
fail-fast: true
|
||||||
matrix:
|
matrix:
|
||||||
variant: [cs4398, ak4490, evk]
|
variant: [cs4398, ak4490, evk]
|
||||||
|
# Job-scoped on purpose: the runner also injects workflow env into action containers, where it
|
||||||
|
# would override the cli image's own toolchain paths.
|
||||||
env:
|
env:
|
||||||
FEATURES: ${{ matrix.variant }},hid
|
FEATURES: ${{ matrix.variant }},hid
|
||||||
|
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
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -69,10 +69,6 @@ jobs:
|
|||||||
|
|
||||||
cli:
|
cli:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
|
||||||
# Bundles the Rust toolchain, zig and a macOS SDK, which the generic builder images lack;
|
|
||||||
# we cross-compile every target from here with cargo-zigbuild.
|
|
||||||
image: ghcr.io/rust-cross/cargo-zigbuild:latest
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -81,64 +77,31 @@ jobs:
|
|||||||
- x86_64-pc-windows-gnu
|
- x86_64-pc-windows-gnu
|
||||||
- x86_64-unknown-linux-musl
|
- x86_64-unknown-linux-musl
|
||||||
- universal2-apple-darwin
|
- universal2-apple-darwin
|
||||||
env:
|
|
||||||
RUSTUP_HOME: /usr/local/rustup
|
|
||||||
CARGO_HOME: /usr/local/cargo
|
|
||||||
steps:
|
steps:
|
||||||
# JavaScript actions need node, which the rust-cross image does not ship. Install it (and the
|
|
||||||
# rest of the tooling the actions rely on) before anything else, as a shell step.
|
|
||||||
- name: Install Actions tooling
|
|
||||||
run: |
|
|
||||||
apt-get update
|
|
||||||
apt-get install -y --no-install-recommends ca-certificates curl git zip zstd
|
|
||||||
if ! command -v node > /dev/null; then
|
|
||||||
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
|
|
||||||
apt-get install -y --no-install-recommends nodejs
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Cache rustup
|
# Building and packaging both happen in .gitea/actions/cli-build, whose image the runner
|
||||||
|
# builds from its Dockerfile and keeps in the Docker layer cache. That image carries the
|
||||||
|
# toolchain, zig, the macOS SDK and every target, so none of that is installed per job.
|
||||||
|
- name: Cache cargo registry
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: ${{ env.RUSTUP_HOME }}
|
path: .cargo-cache
|
||||||
key: rustup-cli-${{ matrix.target }}-${{ runner.os }}
|
key: cli-registry-${{ hashFiles('**/Cargo.lock') }}
|
||||||
|
restore-keys: cli-registry-
|
||||||
|
|
||||||
- name: Install Rust Toolchain
|
- name: Cache build artifacts
|
||||||
run: |
|
|
||||||
rustup target install ${{ matrix.target }}
|
|
||||||
# cargo-zigbuild builds both architectures and merges them for the universal binary.
|
|
||||||
if [[ "${{ matrix.target }}" == universal2-apple-darwin ]]; then
|
|
||||||
rustup target install aarch64-apple-darwin x86_64-apple-darwin
|
|
||||||
fi
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- name: Cache cargo
|
|
||||||
uses: Swatinem/rust-cache@v2
|
|
||||||
with:
|
|
||||||
shared-key: cli-${{ matrix.target }}
|
|
||||||
|
|
||||||
# compiled libc/compiler-rt are per target, so these stay keyed on it
|
|
||||||
- name: Cache zig build artifacts
|
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: |
|
path: target
|
||||||
~/.cache/zig
|
key: cli-target-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
|
||||||
~/.cache/cargo-zigbuild
|
restore-keys: cli-target-${{ matrix.target }}-
|
||||||
key: zigbuild-cache-${{ matrix.target }}-${{ runner.os }}
|
|
||||||
|
|
||||||
- name: Build cli (${{ matrix.target }})
|
- name: Build cli (${{ matrix.target }})
|
||||||
working-directory: cli
|
uses: ./.gitea/actions/cli-build
|
||||||
run: cargo zigbuild --release --target ${{ matrix.target }}
|
with:
|
||||||
|
target: ${{ matrix.target }}
|
||||||
- name: Package
|
|
||||||
run: |
|
|
||||||
bin=guac-cli
|
|
||||||
[[ "${{ matrix.target }}" == *windows* ]] && bin=guac-cli.exe
|
|
||||||
mkdir -p dist
|
|
||||||
zip -j "dist/guac-cli-${{ matrix.target }}.zip" "target/${{ matrix.target }}/release/$bin"
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
|
|||||||
Reference in new issue
Block a user