Skip to content

Commit ee2106a

Browse files
authored
Add a script to download the latest version. (#134)
This facilitates use in CI.
1 parent 44187d1 commit ee2106a

File tree

2 files changed

+49
-3
lines changed

2 files changed

+49
-3
lines changed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
_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
44
[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._
55

6-
# To build
7-
8-
6+
# Obtaining
7+
To fetch the latest release:
8+
```
9+
curl -sSL https://raw.githubusercontent.com/mongodb-labs/migration-verifier/refs/heads/main/download_latest.sh | sh
10+
```
11+
… or, if you prefer to build locally, just do:
912
```
1013
./build.sh
1114
```

download_latest.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/sh
2+
3+
set -o errexit
4+
5+
filename=migration_verifier
6+
7+
RELEASE_URL="https://api.github.com/repos/mongodb-labs/migration-verifier/releases/latest"
8+
9+
OS=$(uname -o | tr '[:upper:]' '[:lower:]' | sed 's|gnu/||')
10+
ARCH=$(uname -m)
11+
if [ "$ARCH" = "aarch64" ]; then
12+
ARCH=arm64
13+
fi
14+
15+
echo "Looks like you’re running $OS on $ARCH."
16+
17+
MANIFEST=$(curl -sSL "$RELEASE_URL")
18+
19+
VERSION=$(printf "%s" "$MANIFEST" | jq -r .name)
20+
21+
echo "Latest release: $VERSION"
22+
23+
ALL_URLS=$(printf "%s" "$MANIFEST" \
24+
| jq -r '.assets[] | .browser_download_url' \
25+
)
26+
27+
DOWNLOAD_URL=$(echo "$ALL_URLS" \
28+
| grep "_${OS}_" | grep "_$ARCH" ||: \
29+
)
30+
31+
if [ -z "$DOWNLOAD_URL" ]; then
32+
echo >&2 "No download URL found for $OS/$ARCH:"
33+
echo >&2 "$ALL_URLS"
34+
exit 1
35+
fi
36+
37+
echo "Downloading $DOWNLOAD_URL"
38+
39+
curl -sSL "$DOWNLOAD_URL" > "$filename"
40+
41+
chmod +x "$filename"
42+
43+
echo "✅ Migration Verifier $VERSION is now saved as $filename."

0 commit comments

Comments
 (0)