cringe
This commit is contained in:
39
scripts/build-agent-native.sh
Executable file
39
scripts/build-agent-native.sh
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
set -Eeuo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
readonly SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
||||
readonly REPOSITORY_ROOT="$(cd -- "$SCRIPT_DIR/.." && pwd)"
|
||||
readonly OUTPUT_DIRECTORY="${1:-$REPOSITORY_ROOT/dist}"
|
||||
|
||||
[[ "$(uname -s)" == Linux ]] || {
|
||||
printf 'error: the agent must be built on Linux; macOS produces a Mach-O binary, not a Linux ELF binary\n' >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
case "$(uname -m)" in
|
||||
x86_64|amd64)
|
||||
RELEASE_ARCHITECTURE="amd64"
|
||||
;;
|
||||
aarch64|arm64)
|
||||
RELEASE_ARCHITECTURE="arm64"
|
||||
;;
|
||||
*)
|
||||
printf 'error: unsupported build architecture: %s\n' "$(uname -m)" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
command -v cargo >/dev/null || { printf 'error: cargo is required\n' >&2; exit 1; }
|
||||
|
||||
cargo build \
|
||||
--manifest-path "$REPOSITORY_ROOT/agent/Cargo.toml" \
|
||||
--release \
|
||||
--locked
|
||||
|
||||
"$SCRIPT_DIR/package-agent-release.sh" \
|
||||
--output "$OUTPUT_DIRECTORY" \
|
||||
"--$RELEASE_ARCHITECTURE" "$REPOSITORY_ROOT/agent/target/release/vps-agent"
|
||||
|
||||
printf 'release artifact prepared in %s for linux/%s\n' \
|
||||
"$OUTPUT_DIRECTORY" "$RELEASE_ARCHITECTURE"
|
||||
Reference in New Issue
Block a user