Repository navigation
Expand file tree
/
Copy pathaction.yml
More file actions
66 lines (63 loc) · 2.92 KB
/
Copy pathaction.yml
File metadata and controls
66 lines (63 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: "fullrust static build"
description: "Build a Rust crate into a libc-free, fully-static Linux binary (x86_64, aarch64, i686 or armv7 fullrust target) using the fullrust toolchain image (no libc, no C toolchain)."
branding:
icon: package
color: orange
# Runs the prebuilt fullrust toolchain image against your checked-out crate. The
# image ships a patched rustc with the built-in fullrust targets (default
# `x86_64-unknown-linux-fullrust`; pick another with `target:`) and the
# ecosystem forks — getrandom, rustix, socket2, mio, tokio — as an
# auto-applied [patch.crates-io]; your
# Cargo.toml is never modified. Any unmodified crate builds into a static,
# libc-free binary — no attributes, no fullrust dependency.
inputs:
command:
description: "cargo subcommand: build, test, run, check, clippy, …"
default: "build"
args:
description: "Arguments passed to cargo (e.g. `--release --bin myapp`)."
default: "--release"
target:
description: >-
Target triple (blank = the image default, x86_64-unknown-linux-fullrust).
Also: aarch64-unknown-linux-fullrust, i686-unknown-linux-fullrust,
armv7-unknown-linux-fullrusteabihf (panic=abort). The image must ship it
(images built before multi-arch support only have x86_64). `run`/`test`
on aarch64/armv7 execute under the qemu-user bundled in the image.
default: ""
working-directory:
description: "Directory containing the crate to build."
default: "."
image:
description: "fullrust toolchain image (override to pin a digest or version)."
default: "ghcr.io/karpeleslab/fullrust:latest"
no-ecosystem:
description: "Skip the ecosystem [patch.crates-io] injection (getrandom, rustix, socket2, mio, tokio forks)."
default: "false"
runs:
using: composite
steps:
- name: Build with the fullrust toolchain image
shell: bash
working-directory: ${{ inputs.working-directory }}
# Inputs are passed via env (not interpolated into the script) to avoid
# shell-injection; `$FR_ARGS` is intentionally word-split into cargo args.
env:
FR_IMAGE: ${{ inputs.image }}
FR_COMMAND: ${{ inputs.command }}
FR_ARGS: ${{ inputs.args }}
FR_NO_ECO: ${{ inputs.no-ecosystem }}
FR_TARGET: ${{ inputs.target }}
run: |
set -euo pipefail
run=(docker run --rm -v "$PWD":/src -w /src)
[ "$FR_NO_ECO" = "true" ] && run+=(-e FULLRUST_NO_ECOSYSTEM=1)
[ -n "$FR_TARGET" ] && run+=(-e "CARGO_BUILD_TARGET=$FR_TARGET")
run+=("$FR_IMAGE" "$FR_COMMAND" $FR_ARGS)
echo "::group::${run[*]}"
"${run[@]}"
echo "::endgroup::"
# The container builds as root; return outputs to the runner user so
# later steps (packaging, upload-artifact) can manage them.
[ -d target ] && sudo chown -R "$(id -u):$(id -g)" target || true
echo "Static binaries under: target/${FR_TARGET:-x86_64-unknown-linux-fullrust}/"