73 lines
1.5 KiB
Bash
Executable File
73 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
readonly REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
|
readonly BUILD_DIR="$(mktemp -d "${TMPDIR:-/tmp}/skill-clis.XXXXXX")"
|
|
|
|
cleanup() {
|
|
rm -rf "${BUILD_DIR}"
|
|
}
|
|
|
|
trap cleanup EXIT INT TERM
|
|
|
|
require_command() {
|
|
local cmd="$1"
|
|
if ! command -v "${cmd}" >/dev/null 2>&1; then
|
|
printf 'missing required command: %s\n' "${cmd}" >&2
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
build_binary() {
|
|
local name="$1"
|
|
local package_path="$2"
|
|
local output_path="${BUILD_DIR}/${name}"
|
|
|
|
printf 'building %s from %s\n' "${name}" "${package_path}" >&2
|
|
(
|
|
cd "${REPO_ROOT}"
|
|
go build -trimpath -o "${output_path}" "${package_path}"
|
|
)
|
|
|
|
printf '%s\n' "${output_path}"
|
|
}
|
|
|
|
install_binary() {
|
|
local source_path="$1"
|
|
shift
|
|
|
|
local destination_path
|
|
for destination_path in "$@"; do
|
|
mkdir -p "$(dirname "${destination_path}")"
|
|
install -m 0755 "${source_path}" "${destination_path}"
|
|
printf 'installed %s\n' "${destination_path}"
|
|
done
|
|
}
|
|
|
|
main() {
|
|
require_command go
|
|
require_command install
|
|
require_command mktemp
|
|
|
|
local inbox_binary
|
|
local orch_binary
|
|
|
|
inbox_binary="$(build_binary inbox ./cmd/inbox)"
|
|
orch_binary="$(build_binary orch ./cmd/orch)"
|
|
|
|
install_binary \
|
|
"${inbox_binary}" \
|
|
"${REPO_ROOT}/skills/inbox/assets/inbox"
|
|
|
|
install_binary \
|
|
"${orch_binary}" \
|
|
"${REPO_ROOT}/skills/orch/assets/orch" \
|
|
"${REPO_ROOT}/skills/council-review/assets/orch"
|
|
|
|
printf 'skill CLI packaging complete\n'
|
|
}
|
|
|
|
main "$@"
|