Add bin/repo deploy and --host on every server-facing command
deploy runs build then push, which is the whole workflow on a local build machine. It resolves the build host before building so a missing --host fails in a second rather than after a long compile. --host now overrides $OMARCHY_BUILD_HOST and .build-host on deploy, push, and the build trigger in omarchy-pkgs release, so a server can be named per invocation without arming the release auto-trigger. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
bf53101bbf
commit
c5f5f1c12c
Executable
+131
@@ -0,0 +1,131 @@
|
||||
#!/bin/bash
|
||||
# Build packages locally, then publish them from the build host.
|
||||
#
|
||||
# The two halves of shipping a package built on a local machine: bin/build
|
||||
# produces the artifacts, bin/push-build hands them to the host that owns the
|
||||
# signing key and the complete repository.
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR=$(realpath "${BASH_SOURCE[0]%/*}")
|
||||
BUILD_ROOT=$(realpath "$SCRIPT_DIR/..")
|
||||
source "$BUILD_ROOT/helpers/message-helpers.sh"
|
||||
source "$BUILD_ROOT/helpers/paths.sh"
|
||||
|
||||
PACKAGES=()
|
||||
HOST=""
|
||||
REMOTE_ROOT=""
|
||||
DRY_RUN=false
|
||||
ASSUME_YES=false
|
||||
|
||||
print_header "Deploy (build + push)"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--arch)
|
||||
ARCH="$2"
|
||||
update_arch_paths
|
||||
shift 2
|
||||
;;
|
||||
--mirror)
|
||||
MIRROR="$2"
|
||||
if [[ "$MIRROR" != "edge" && "$MIRROR" != "stable" ]]; then
|
||||
print_error "Invalid mirror: $MIRROR (must be 'edge' or 'stable')"
|
||||
exit 1
|
||||
fi
|
||||
update_arch_paths
|
||||
shift 2
|
||||
;;
|
||||
--package)
|
||||
shift
|
||||
while [[ $# -gt 0 && ! "$1" =~ ^-- ]]; do
|
||||
PACKAGES+=("$1")
|
||||
shift
|
||||
done
|
||||
;;
|
||||
--host)
|
||||
HOST="$2"
|
||||
shift 2
|
||||
;;
|
||||
--remote-root)
|
||||
REMOTE_ROOT="$2"
|
||||
shift 2
|
||||
;;
|
||||
--dry-run)
|
||||
DRY_RUN=true
|
||||
shift
|
||||
;;
|
||||
-y | --yes)
|
||||
ASSUME_YES=true
|
||||
shift
|
||||
;;
|
||||
-h | --help)
|
||||
echo "Usage: $0 [OPTIONS]"
|
||||
echo ""
|
||||
echo "Build packages here, then publish them from the build host."
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " --arch <arch> Target architecture (default: x86_64)"
|
||||
echo " --mirror <mirror> Mirror to publish to (edge or stable, default: edge)"
|
||||
echo " --package <names> Build and push only these packages (space-separated)"
|
||||
echo " --host <host> ssh destination (default: \$OMARCHY_BUILD_HOST or .build-host)"
|
||||
echo " --remote-root <path> Repository path on the host (default: /root/omarchy-pkgs)"
|
||||
echo " --dry-run Show the plan, build nothing and transfer nothing"
|
||||
echo " -y, --yes Do not ask for confirmation before publishing"
|
||||
echo " -h, --help Show this help message"
|
||||
echo ""
|
||||
echo "Examples:"
|
||||
echo " $0 --package nvidia-580xx-utils"
|
||||
echo " $0 --package nvidia-580xx-utils --host root@example.com"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
print_error "Unknown option: $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo ""
|
||||
print_info "This will:"
|
||||
echo " 1. Build packages locally"
|
||||
echo " 2. Upload them to the build host"
|
||||
echo " 3. Sign, promote, update and sync them there"
|
||||
echo ""
|
||||
|
||||
BUILD_ARGS=("--arch" "$ARCH" "--mirror" "$MIRROR")
|
||||
PUSH_ARGS=("--arch" "$ARCH" "--mirror" "$MIRROR")
|
||||
|
||||
if [[ ${#PACKAGES[@]} -gt 0 ]]; then
|
||||
BUILD_ARGS+=("--package" "${PACKAGES[@]}")
|
||||
PUSH_ARGS+=("--package" "${PACKAGES[@]}")
|
||||
fi
|
||||
[[ -n "$HOST" ]] && PUSH_ARGS+=("--host" "$HOST")
|
||||
[[ -n "$REMOTE_ROOT" ]] && PUSH_ARGS+=("--remote-root" "$REMOTE_ROOT")
|
||||
[[ "$DRY_RUN" == true ]] && BUILD_ARGS+=("--dry-run") && PUSH_ARGS+=("--dry-run")
|
||||
[[ "$ASSUME_YES" == true ]] && PUSH_ARGS+=("--yes")
|
||||
|
||||
# Resolve the host before spending build time on packages that cannot ship.
|
||||
if [[ "$DRY_RUN" != true ]]; then
|
||||
resolved_host="$HOST"
|
||||
if [[ -z "$resolved_host" ]]; then
|
||||
resolved_host="${OMARCHY_BUILD_HOST:-}"
|
||||
[[ -z "$resolved_host" && -f "$BUILD_ROOT/.build-host" ]] && resolved_host=$(<"$BUILD_ROOT/.build-host")
|
||||
fi
|
||||
if [[ -z "$resolved_host" ]]; then
|
||||
print_error "No build host configured"
|
||||
echo ""
|
||||
echo "Pass --host, set OMARCHY_BUILD_HOST, or write the destination to:"
|
||||
echo " $BUILD_ROOT/.build-host"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
print_info "Step 1/2: Building..."
|
||||
echo ""
|
||||
"$SCRIPT_DIR/build" "${BUILD_ARGS[@]}"
|
||||
echo ""
|
||||
|
||||
print_info "Step 2/2: Pushing to the build host..."
|
||||
echo ""
|
||||
"$SCRIPT_DIR/push-build" "${PUSH_ARGS[@]}"
|
||||
+5
-1
@@ -43,6 +43,8 @@ Options for release:
|
||||
--commit <sha> (rc) Upstream commit to pin (default: tip of --ref)
|
||||
--ref <branch> (rc) Upstream branch whose tip to pin (default: $DEFAULT_RC_REF)
|
||||
--yes Skip confirmation prompts
|
||||
--host <host> ssh destination of the build host to trigger, overriding
|
||||
\$OMARCHY_BUILD_HOST and .build-host
|
||||
--no-push Rewrite and commit locally; skip push and build trigger
|
||||
--pr When releasing from a non-master branch, open a GitHub PR
|
||||
to master with gh after pushing
|
||||
@@ -312,7 +314,8 @@ regenerate_checksums() {
|
||||
# --- trigger -----------------------------------------------------------------
|
||||
|
||||
trigger_build_host() {
|
||||
local host="${OMARCHY_BUILD_HOST:-}"
|
||||
local host="${BUILD_HOST_OVERRIDE:-}"
|
||||
[[ -z "$host" ]] && host="${OMARCHY_BUILD_HOST:-}"
|
||||
[[ -z "$host" && -f "$BUILD_ROOT/.build-host" ]] && host=$(<"$BUILD_ROOT/.build-host")
|
||||
if [[ -z "$host" ]]; then
|
||||
print_info "No build host configured (set OMARCHY_BUILD_HOST or $BUILD_ROOT/.build-host)."
|
||||
@@ -341,6 +344,7 @@ cmd_release() {
|
||||
--force) force=true; shift ;;
|
||||
--commit) commit_arg="$2"; shift 2 ;;
|
||||
--ref) ref="$2"; shift 2 ;;
|
||||
--host) BUILD_HOST_OVERRIDE="$2"; shift 2 ;;
|
||||
--yes) assume_yes=true; shift ;;
|
||||
--dry-run) dry_run=true; shift ;;
|
||||
-h | --help) show_usage; exit 0 ;;
|
||||
|
||||
@@ -59,6 +59,7 @@ show_usage() {
|
||||
echo " remove Remove a specific package"
|
||||
echo " sync Sync repository to remote"
|
||||
echo " push Upload local builds to the build host and publish them there"
|
||||
echo " deploy Build locally, then push: one command for a local build machine"
|
||||
echo ""
|
||||
echo "Typical workflows:"
|
||||
echo " $0 release # Complete release workflow"
|
||||
@@ -130,6 +131,10 @@ push)
|
||||
"$SCRIPT_DIR/push-build" "$@" 2>&1 | tee "$LOG_FILE"
|
||||
exit ${PIPESTATUS[0]}
|
||||
;;
|
||||
deploy)
|
||||
"$SCRIPT_DIR/deploy" "$@" 2>&1 | tee "$LOG_FILE"
|
||||
exit ${PIPESTATUS[0]}
|
||||
;;
|
||||
-h | --help | help)
|
||||
show_usage
|
||||
;;
|
||||
|
||||
Reference in New Issue
Block a user