diff --git a/README.md b/README.md index 7a9ac20c..7a77e121 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,12 @@ _If verifying a migration done via [mongosync](https://www.mongodb.com/docs/cluster-to-cluster-sync/current/), please check if it is possible to use the [embedded verifier](https://www.mongodb.com/docs/cluster-to-cluster-sync/current/reference/verification/embedded/#std-label-c2c-embedded-verifier) as that is the preferred approach for verification._ -# To build - - +# Obtaining +To fetch the latest release: +``` +curl -sSL https://raw.githubusercontent.com/mongodb-labs/migration-verifier/refs/heads/main/download_latest.sh | sh +``` +… or, if you prefer to build locally, just do: ``` ./build.sh ``` diff --git a/download_latest.sh b/download_latest.sh new file mode 100755 index 00000000..ab1b08f2 --- /dev/null +++ b/download_latest.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +set -o errexit + +filename=migration_verifier + +RELEASE_URL="https://api.github.com/repos/mongodb-labs/migration-verifier/releases/latest" + +OS=$(uname -o | tr '[:upper:]' '[:lower:]' | sed 's|gnu/||') +ARCH=$(uname -m) +if [ "$ARCH" = "aarch64" ]; then + ARCH=arm64 +fi + +echo "Looks like you’re running $OS on $ARCH." + +MANIFEST=$(curl -sSL "$RELEASE_URL") + +VERSION=$(printf "%s" "$MANIFEST" | jq -r .name) + +echo "Latest release: $VERSION" + +ALL_URLS=$(printf "%s" "$MANIFEST" \ + | jq -r '.assets[] | .browser_download_url' \ +) + +DOWNLOAD_URL=$(echo "$ALL_URLS" \ + | grep "_${OS}_" | grep "_$ARCH" ||: \ +) + +if [ -z "$DOWNLOAD_URL" ]; then + echo >&2 "No download URL found for $OS/$ARCH:" + echo >&2 "$ALL_URLS" + exit 1 +fi + +echo "Downloading $DOWNLOAD_URL …" + +curl -sSL "$DOWNLOAD_URL" > "$filename" + +chmod +x "$filename" + +echo "✅ Migration Verifier $VERSION is now saved as $filename."