-
Notifications
You must be signed in to change notification settings - Fork 15
Add a script to download the latest version. #134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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." |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is more complex than it needs to be. Once you know the filename you want to download, you can download this:
https://github.com/mongodb-labs/migration-verifier/releases/latest/download/$FILENAMEThere's no need to hit the API and parse the response.
This does mean you need to calculate the filename directly instead of getting it from the API response, but it seems a lot simpler. You can see how I do this for ubi at https://github.com/houseabsolute/ubi/blob/master/bootstrap/bootstrap-ubi.sh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’d rather not build in a dependency on the filename format.
OK to keep as-is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, that's fine. But I'd note that we do control the filename!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You know that & I know that, but the next maintainer may be a new hire or intern.