Skip to content

Commit 0c45b4d

Browse files
haarchrijcogilvie
authored andcommitted
feat(install): update the install script to get the correct binaries
Signed-off-by: Christopher Haar <[email protected]>
1 parent f8702cc commit 0c45b4d

File tree

2 files changed

+65
-32
lines changed

2 files changed

+65
-32
lines changed

README.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,30 @@ The `crossplane-diff` tool helps you:
1717

1818
## Installation
1919

20-
### Download Pre-built Binary
20+
### Installing the CLI
2121

22-
Download the latest release from the [releases page](https://github.com/crossplane-contrib/crossplane-diff/releases).
22+
You can install the latest version of **crossplane-diff** automatically using the provided install script:
2323

24-
### Build from Source
24+
```bash
25+
curl -sL "https://raw.githubusercontent.com/crossplane-contrib/crossplane-diff/main/install.sh" | sh
26+
```
27+
28+
The script detects your operating system and CPU architecture and downloads the latest release from GitHub.
29+
30+
### Installing the CLI with a specific Version
31+
32+
You can set the VERSION environment variable before running the script:
33+
34+
```bash
35+
curl -sL "https://raw.githubusercontent.com/crossplane-contrib/crossplane-diff/main/install.sh" | VERSION=v0.3.1 sh
36+
```
37+
38+
### Building the CLI
2539

2640
```bash
2741
git clone https://github.com/crossplane-contrib/crossplane-diff.git
2842
cd crossplane-diff
29-
go build -o crossplane-diff ./cmd/diff
43+
earthly -P +build
3044
```
3145

3246
## Usage
@@ -202,7 +216,7 @@ The tool prioritizes **accuracy above all else**:
202216
### Caveats
203217

204218
The tool does not take a snapshot of cluster state before processing, so changes made to the cluster during execution
205-
may affect results.
219+
may affect results.
206220

207221
## Documentation
208222

install.sh

Lines changed: 46 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,77 +2,96 @@
22

33
set -eu
44

5-
XP_CHANNEL=${XP_CHANNEL:-stable}
6-
XP_VERSION=${XP_VERSION:-current}
5+
# Use "latest" if not specified, otherwise accept explicit tag like v0.3.1
6+
VERSION=${VERSION:-latest}
77

88
os=$(uname -s)
99
arch=$(uname -m)
1010
OS=${OS:-"${os}"}
1111
ARCH=${ARCH:-"${arch}"}
1212
OS_ARCH=""
13-
14-
BIN=${BIN:-crank}
13+
BIN="crossplane-diff"
1514

1615
unsupported_arch() {
1716
local os=$1
1817
local arch=$2
19-
echo "Crossplane does not support $os / $arch at this time."
18+
echo "❌ crossplane-diff does not support $os / $arch at this time."
2019
exit 1
2120
}
2221

22+
# Detect OS/Architecture
2323
case $OS in
2424
CYGWIN* | MINGW64* | Windows*)
25-
if [ $ARCH = "x86_64" ]
26-
then
27-
OS_ARCH=windows_amd64
28-
BIN=crank.exe
25+
if [ "$ARCH" = "x86_64" ]; then
26+
OS_ARCH="windows_amd64.exe"
27+
BIN="crossplane-diff.exe"
2928
else
30-
unsupported_arch $OS $ARCH
29+
unsupported_arch "$OS" "$ARCH"
3130
fi
3231
;;
3332
Darwin)
3433
case $ARCH in
3534
x86_64|amd64)
36-
OS_ARCH=darwin_amd64
35+
OS_ARCH="darwin_amd64"
3736
;;
3837
arm64)
39-
OS_ARCH=darwin_arm64
38+
OS_ARCH="darwin_arm64"
4039
;;
4140
*)
42-
unsupported_arch $OS $ARCH
41+
unsupported_arch "$OS" "$ARCH"
4342
;;
4443
esac
4544
;;
4645
Linux)
4746
case $ARCH in
4847
x86_64|amd64)
49-
OS_ARCH=linux_amd64
48+
OS_ARCH="linux_amd64"
5049
;;
5150
arm64|aarch64)
52-
OS_ARCH=linux_arm64
51+
OS_ARCH="linux_arm64"
52+
;;
53+
arm)
54+
OS_ARCH="linux_arm"
55+
;;
56+
ppc64le)
57+
OS_ARCH="linux_ppc64le"
5358
;;
5459
*)
55-
unsupported_arch $OS $ARCH
60+
unsupported_arch "$OS" "$ARCH"
5661
;;
5762
esac
5863
;;
5964
*)
60-
unsupported_arch $OS $ARCH
65+
unsupported_arch "$OS" "$ARCH"
6166
;;
6267
esac
6368

64-
url="https://releases.crossplane.io/${XP_CHANNEL}/${XP_VERSION}/bin/${OS_ARCH}/${BIN}"
65-
if ! curl -sfLo crossplane "${url}"; then
66-
echo "Failed to download Crossplane CLI. Please make sure version ${XP_VERSION} exists on channel ${XP_CHANNEL}."
69+
# Choose correct URL pattern
70+
if [ "$VERSION" = "latest" ]; then
71+
url="https://github.com/crossplane-contrib/crossplane-diff/releases/latest/download/crossplane-diff_${OS_ARCH}"
72+
else
73+
url="https://github.com/crossplane-contrib/crossplane-diff/releases/download/${VERSION}/crossplane-diff_${OS_ARCH}"
74+
fi
75+
76+
echo "📦 Downloading crossplane-diff (${VERSION}) for ${OS_ARCH}..."
77+
echo "➡️ ${url}"
78+
echo
79+
80+
# Download the binary
81+
if ! curl -sfLo "${BIN}" "${url}"; then
82+
echo "❌ Failed to download crossplane-diff version '${VERSION}'."
83+
echo "Please check available versions at:"
84+
echo " https://github.com/crossplane-contrib/crossplane-diff/releases"
6785
exit 1
6886
fi
6987

70-
chmod +x crossplane
88+
chmod +x "${BIN}"
7189

72-
echo "crossplane CLI downloaded successfully! Run the following commands to finish installing it:"
73-
echo
74-
echo sudo mv crossplane /usr/local/bin
75-
echo crossplane --help
7690
echo
77-
echo "Visit https://crossplane.io to get started. 🚀"
78-
echo "Have a nice day! 👋\n"
91+
echo "✅ crossplane-diff downloaded successfully!"
92+
echo
93+
echo "To finish installation, run:"
94+
echo " sudo mv ${BIN} /usr/local/bin/"
95+
echo " crossplane-diff --help"
96+
echo
97+
echo "Visit https://github.com/crossplane-contrib/crossplane-diff for more info 🚀"

0 commit comments

Comments
 (0)