mirror of
https://github.com/ModernRelay/omnigraph.git
synced 2026-06-09 01:35:18 +02:00
Fix public binary install flow
This commit is contained in:
parent
cbb312e74f
commit
816b24d05e
8 changed files with 75 additions and 40 deletions
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
REPO_SLUG="${REPO_SLUG:-ModernRelay/omnigraph-public}"
|
||||
REPO_SLUG="${REPO_SLUG:-ModernRelay/omnigraph}"
|
||||
SOURCE_REF="${SOURCE_REF:-main}"
|
||||
INSTALL_DIR="${INSTALL_DIR:-$HOME/.local/bin}"
|
||||
TMP_ROOT="${TMPDIR:-/tmp}"
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
REPO_SLUG="${REPO_SLUG:-ModernRelay/omnigraph-public}"
|
||||
REPO_SLUG="${REPO_SLUG:-ModernRelay/omnigraph}"
|
||||
INSTALL_DIR="${INSTALL_DIR:-$HOME/.local/bin}"
|
||||
RELEASE_CHANNEL="${RELEASE_CHANNEL:-stable}"
|
||||
VERSION="${VERSION:-}"
|
||||
TMP_ROOT="${TMPDIR:-/tmp}"
|
||||
WORKDIR=""
|
||||
SELECTED_CHANNEL=""
|
||||
|
||||
log() {
|
||||
printf '==> %s\n' "$*"
|
||||
|
|
@ -61,12 +62,14 @@ checksum_command() {
|
|||
}
|
||||
|
||||
release_base_url() {
|
||||
local channel="${1:-$RELEASE_CHANNEL}"
|
||||
|
||||
if [ -n "$VERSION" ]; then
|
||||
printf 'https://github.com/%s/releases/download/%s\n' "$REPO_SLUG" "$VERSION"
|
||||
return
|
||||
fi
|
||||
|
||||
case "$RELEASE_CHANNEL" in
|
||||
case "$channel" in
|
||||
stable)
|
||||
printf 'https://github.com/%s/releases/latest/download\n' "$REPO_SLUG"
|
||||
;;
|
||||
|
|
@ -74,7 +77,7 @@ release_base_url() {
|
|||
printf 'https://github.com/%s/releases/download/edge\n' "$REPO_SLUG"
|
||||
;;
|
||||
*)
|
||||
die "unsupported RELEASE_CHANNEL '$RELEASE_CHANNEL' (expected stable or edge)"
|
||||
die "unsupported RELEASE_CHANNEL '$channel' (expected stable or edge)"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
|
@ -99,22 +102,46 @@ verify_checksum() {
|
|||
[ "$actual" = "$expected" ] || die "checksum verification failed for $(basename "$archive")"
|
||||
}
|
||||
|
||||
download_release_files() {
|
||||
local base_url="$1"
|
||||
local asset_name="$2"
|
||||
local checksum_name="$3"
|
||||
local archive="$4"
|
||||
local checksum="$5"
|
||||
|
||||
curl -fsSL "$base_url/$asset_name" -o "$archive" || return 1
|
||||
curl -fsSL "$base_url/$checksum_name" -o "$checksum" || return 1
|
||||
}
|
||||
|
||||
install_from_release() {
|
||||
local asset archive checksum base_url
|
||||
local asset asset_stem archive checksum base_url
|
||||
|
||||
asset="$(platform_asset_name)" || die "no prebuilt binary is available for $(uname -s)/$(uname -m)"
|
||||
asset_stem="${asset%.tar.gz}"
|
||||
WORKDIR="$(mktemp -d "$TMP_ROOT/omnigraph-install.XXXXXX")"
|
||||
archive="$WORKDIR/$asset"
|
||||
checksum="$WORKDIR/$asset.sha256"
|
||||
base_url="$(release_base_url)"
|
||||
checksum="$WORKDIR/$asset_stem.sha256"
|
||||
|
||||
log "Downloading $asset"
|
||||
curl -fsSL \
|
||||
"$base_url/$asset" \
|
||||
-o "$archive" || die "no published binary found for $asset; use scripts/install-source.sh or build from source"
|
||||
curl -fsSL \
|
||||
"$base_url/$asset.sha256" \
|
||||
-o "$checksum" || die "checksum file for $asset was not found"
|
||||
if [ -n "$VERSION" ]; then
|
||||
SELECTED_CHANNEL="$VERSION"
|
||||
base_url="$(release_base_url)"
|
||||
log "Downloading $asset from $VERSION"
|
||||
download_release_files "$base_url" "$asset" "$asset_stem.sha256" "$archive" "$checksum" || die "no published binary found for $asset at release $VERSION"
|
||||
else
|
||||
SELECTED_CHANNEL="$RELEASE_CHANNEL"
|
||||
base_url="$(release_base_url "$SELECTED_CHANNEL")"
|
||||
log "Downloading $asset from $SELECTED_CHANNEL"
|
||||
if ! download_release_files "$base_url" "$asset" "$asset_stem.sha256" "$archive" "$checksum"; then
|
||||
if [ "$RELEASE_CHANNEL" != "stable" ]; then
|
||||
die "no published binary found for $asset on channel $RELEASE_CHANNEL"
|
||||
fi
|
||||
|
||||
log "Stable release binaries are not published yet; falling back to edge"
|
||||
SELECTED_CHANNEL="edge"
|
||||
base_url="$(release_base_url "$SELECTED_CHANNEL")"
|
||||
download_release_files "$base_url" "$asset" "$asset_stem.sha256" "$archive" "$checksum" || die "no published binary found for $asset on stable or edge; use scripts/install-source.sh or build from source"
|
||||
fi
|
||||
fi
|
||||
|
||||
verify_checksum "$archive" "$checksum"
|
||||
tar -C "$WORKDIR" -xzf "$archive" || die "failed to unpack $asset"
|
||||
|
|
@ -134,6 +161,10 @@ Verify:
|
|||
|
||||
EOF
|
||||
|
||||
if [ -n "$SELECTED_CHANNEL" ]; then
|
||||
printf 'Installed from release channel: %s\n' "$SELECTED_CHANNEL"
|
||||
fi
|
||||
|
||||
case ":$PATH:" in
|
||||
*":$INSTALL_DIR:"*)
|
||||
;;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
REPO_SLUG="${REPO_SLUG:-ModernRelay/omnigraph-public}"
|
||||
REPO_SLUG="${REPO_SLUG:-ModernRelay/omnigraph}"
|
||||
SOURCE_REF="${SOURCE_REF:-main}"
|
||||
RELEASE_CHANNEL="${RELEASE_CHANNEL:-edge}"
|
||||
WORKDIR="${WORKDIR:-$PWD/.omnigraph-rustfs-demo}"
|
||||
|
|
@ -162,14 +162,15 @@ download_fixture_files() {
|
|||
}
|
||||
|
||||
download_release_binaries() {
|
||||
local asset archive_dir archive_path checksum_path base_url
|
||||
local asset asset_stem archive_dir archive_path checksum_path base_url
|
||||
|
||||
[ "$FORCE_BUILD" = "1" ] && return 1
|
||||
|
||||
asset="$(platform_asset_name)" || return 1
|
||||
asset_stem="${asset%.tar.gz}"
|
||||
archive_dir="$WORKDIR/release"
|
||||
archive_path="$archive_dir/$asset"
|
||||
checksum_path="$archive_dir/$asset.sha256"
|
||||
checksum_path="$archive_dir/$asset_stem.sha256"
|
||||
mkdir -p "$archive_dir" "$WORKDIR/bin"
|
||||
base_url="$(release_base_url)"
|
||||
|
||||
|
|
@ -178,7 +179,7 @@ download_release_binaries() {
|
|||
"$base_url/$asset" \
|
||||
-o "$archive_path" || return 1
|
||||
curl -fsSL \
|
||||
"$base_url/$asset.sha256" \
|
||||
"$base_url/$asset_stem.sha256" \
|
||||
-o "$checksum_path" || return 1
|
||||
verify_checksum "$archive_path" "$checksum_path" || return 1
|
||||
tar -C "$WORKDIR/bin" -xzf "$archive_path" || return 1
|
||||
|
|
@ -231,10 +232,12 @@ setup_binaries() {
|
|||
elif [ -n "$repo_root" ]; then
|
||||
FIXTURE_DIR="$repo_root/crates/omnigraph/tests/fixtures"
|
||||
fi
|
||||
elif [ -n "$repo_root" ]; then
|
||||
build_from_source "$repo_root"
|
||||
elif ! download_release_binaries; then
|
||||
build_from_source
|
||||
if [ -n "$repo_root" ]; then
|
||||
build_from_source "$repo_root"
|
||||
else
|
||||
build_from_source
|
||||
fi
|
||||
fi
|
||||
|
||||
[ -x "$BIN_DIR/omnigraph" ] || die "omnigraph binary not found in $BIN_DIR"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue