From 0c45b4d259fb681ab260a108ee547f04683c24f8 Mon Sep 17 00:00:00 2001 From: Christopher Haar Date: Fri, 31 Oct 2025 12:04:08 +0100 Subject: [PATCH] feat(install): update the install script to get the correct binaries Signed-off-by: Christopher Haar --- README.md | 24 ++++++++++++++---- install.sh | 73 ++++++++++++++++++++++++++++++++++-------------------- 2 files changed, 65 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 9026d78..1cb3917 100644 --- a/README.md +++ b/README.md @@ -17,16 +17,30 @@ The `crossplane-diff` tool helps you: ## Installation -### Download Pre-built Binary +### Installing the CLI -Download the latest release from the [releases page](https://github.com/crossplane-contrib/crossplane-diff/releases). +You can install the latest version of **crossplane-diff** automatically using the provided install script: -### Build from Source +```bash +curl -sL "https://raw.githubusercontent.com/crossplane-contrib/crossplane-diff/main/install.sh" | sh +``` + +The script detects your operating system and CPU architecture and downloads the latest release from GitHub. + +### Installing the CLI with a specific Version + +You can set the VERSION environment variable before running the script: + +```bash +curl -sL "https://raw.githubusercontent.com/crossplane-contrib/crossplane-diff/main/install.sh" | VERSION=v0.3.1 sh +``` + +### Building the CLI ```bash git clone https://github.com/crossplane-contrib/crossplane-diff.git cd crossplane-diff -go build -o crossplane-diff ./cmd/diff +earthly -P +build ``` ## Usage @@ -202,7 +216,7 @@ The tool prioritizes **accuracy above all else**: ### Caveats The tool does not take a snapshot of cluster state before processing, so changes made to the cluster during execution -may affect results. +may affect results. ## Documentation diff --git a/install.sh b/install.sh index d321d23..f3f7ded 100755 --- a/install.sh +++ b/install.sh @@ -2,77 +2,96 @@ set -eu -XP_CHANNEL=${XP_CHANNEL:-stable} -XP_VERSION=${XP_VERSION:-current} +# Use "latest" if not specified, otherwise accept explicit tag like v0.3.1 +VERSION=${VERSION:-latest} os=$(uname -s) arch=$(uname -m) OS=${OS:-"${os}"} ARCH=${ARCH:-"${arch}"} OS_ARCH="" - -BIN=${BIN:-crank} +BIN="crossplane-diff" unsupported_arch() { local os=$1 local arch=$2 - echo "Crossplane does not support $os / $arch at this time." + echo "❌ crossplane-diff does not support $os / $arch at this time." exit 1 } +# Detect OS/Architecture case $OS in CYGWIN* | MINGW64* | Windows*) - if [ $ARCH = "x86_64" ] - then - OS_ARCH=windows_amd64 - BIN=crank.exe + if [ "$ARCH" = "x86_64" ]; then + OS_ARCH="windows_amd64.exe" + BIN="crossplane-diff.exe" else - unsupported_arch $OS $ARCH + unsupported_arch "$OS" "$ARCH" fi ;; Darwin) case $ARCH in x86_64|amd64) - OS_ARCH=darwin_amd64 + OS_ARCH="darwin_amd64" ;; arm64) - OS_ARCH=darwin_arm64 + OS_ARCH="darwin_arm64" ;; *) - unsupported_arch $OS $ARCH + unsupported_arch "$OS" "$ARCH" ;; esac ;; Linux) case $ARCH in x86_64|amd64) - OS_ARCH=linux_amd64 + OS_ARCH="linux_amd64" ;; arm64|aarch64) - OS_ARCH=linux_arm64 + OS_ARCH="linux_arm64" + ;; + arm) + OS_ARCH="linux_arm" + ;; + ppc64le) + OS_ARCH="linux_ppc64le" ;; *) - unsupported_arch $OS $ARCH + unsupported_arch "$OS" "$ARCH" ;; esac ;; *) - unsupported_arch $OS $ARCH + unsupported_arch "$OS" "$ARCH" ;; esac -url="https://releases.crossplane.io/${XP_CHANNEL}/${XP_VERSION}/bin/${OS_ARCH}/${BIN}" -if ! curl -sfLo crossplane "${url}"; then - echo "Failed to download Crossplane CLI. Please make sure version ${XP_VERSION} exists on channel ${XP_CHANNEL}." +# Choose correct URL pattern +if [ "$VERSION" = "latest" ]; then + url="https://github.com/crossplane-contrib/crossplane-diff/releases/latest/download/crossplane-diff_${OS_ARCH}" +else + url="https://github.com/crossplane-contrib/crossplane-diff/releases/download/${VERSION}/crossplane-diff_${OS_ARCH}" +fi + +echo "📦 Downloading crossplane-diff (${VERSION}) for ${OS_ARCH}..." +echo "➡️ ${url}" +echo + +# Download the binary +if ! curl -sfLo "${BIN}" "${url}"; then + echo "❌ Failed to download crossplane-diff version '${VERSION}'." + echo "Please check available versions at:" + echo " https://github.com/crossplane-contrib/crossplane-diff/releases" exit 1 fi -chmod +x crossplane +chmod +x "${BIN}" -echo "crossplane CLI downloaded successfully! Run the following commands to finish installing it:" -echo -echo sudo mv crossplane /usr/local/bin -echo crossplane --help echo -echo "Visit https://crossplane.io to get started. 🚀" -echo "Have a nice day! 👋\n" +echo "✅ crossplane-diff downloaded successfully!" +echo +echo "To finish installation, run:" +echo " sudo mv ${BIN} /usr/local/bin/" +echo " crossplane-diff --help" +echo +echo "Visit https://github.com/crossplane-contrib/crossplane-diff for more info 🚀"