-
Notifications
You must be signed in to change notification settings - Fork 83
feat: add a download script to facilitate easy use in CI MONGOSH-2687 #2532
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 1 commit
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
4df5b98
add download script
FGasper c1ec95a
Anna’s review feedback
FGasper 588c5e2
Update README.md
FGasper 50bddd8
Update download_latest.sh
FGasper e8d4af8
Extract the crypto library as well.
FGasper 8a9f8cc
Merge branch 'add_download_script' of github.com:FGasper/mongosh into…
FGasper 9fad15d
prettify & add manual download link
FGasper 73fe093
Merge branch 'main' into add_download_script
FGasper 3e1404b
Always output to stderr
FGasper ff93c05
Merge branch 'add_download_script' of github.com:FGasper/mongosh into…
FGasper c47eb09
Update README change to mention `npx mongosh`.
FGasper 5dcb55e
fixup: code review comments
addaleax 8f1242a
Merge branch 'main' into add_download_script
addaleax 9290f20
fixup: run build-info before finishing script
addaleax 170aea3
fixup: add explicit semver ordering test
addaleax c7ed465
fixup: macOS fixes
addaleax 52c0d62
fixup: GHA test
addaleax 2a71d49
fixup: cr daily run
addaleax 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
Some comments aren't visible on the classic Files Changed page.
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,74 @@ | ||
| #!/bin/sh | ||
|
|
||
| set -o errexit | ||
|
|
||
| for tool in jq curl; do | ||
| which "$tool" >/dev/null || { | ||
| echo >&2 "This script requires '$tool'." | ||
| exit 1 | ||
| } | ||
| done | ||
|
|
||
| os=$(uname -o | tr '[:upper:]' '[:lower:]') | ||
| arch=$(uname -m) | ||
|
|
||
| case "$os" in | ||
| *linux) | ||
| ext=tgz | ||
| os=linux | ||
| ;; | ||
| darwin) | ||
| ext=zip | ||
| ;; | ||
| *) | ||
| echo >&2 "This script does not support this OS ($os). Download mongosh manually." | ||
| exit 1 | ||
| esac | ||
|
|
||
| case "$arch" in | ||
| amd64|x86_64) | ||
| arch=x64 | ||
| ;; | ||
| aarch64) | ||
| arch=arm64 | ||
addaleax marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| esac | ||
|
|
||
| urls=$(curl -fsSL https://api.github.com/repos/mongodb-js/mongosh/releases/latest | jq -r '.assets[] | .browser_download_url' | grep -v -e \.sig -e shared -e openssl) | ||
addaleax marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| url=$(printf "%s" "$urls" | grep "\-${os}-${arch}" ||:) | ||
|
|
||
| if [ -z "$url" ]; then | ||
| cat <<EOL | ||
| No download found for $os on $arch; download manually. | ||
| URLs considered: | ||
| $urls | ||
| EOL | ||
| exit 1 | ||
| fi | ||
|
|
||
| case "$ext" in | ||
| zip) | ||
| file=$(mktemp) | ||
|
|
||
| echo "Downloading $url to $file …" | ||
addaleax marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| trap 'rm -f $file' EXIT | ||
FGasper marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| curl -fsSL "$url" > "$file" | ||
| echo "Downloaded $ext file; extracting mongosh …" | ||
|
|
||
| unzip -j "$file" '*/mongosh' | ||
| ;; | ||
| tgz) | ||
| echo "Downloading & extracting from $url …" | ||
|
|
||
| curl -fsSL "$url" | tar -xzf - \ | ||
addaleax marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| --transform "s/.*\///" \ | ||
| --wildcards "**/mongosh" | ||
addaleax marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ;; | ||
| *) | ||
| echo >&2 "Bad file extension: $ext" | ||
| exit 1 | ||
| esac | ||
|
|
||
| echo "Success! 'mongosh' is now saved in this directory." | ||
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.
Uh oh!
There was an error while loading. Please reload this page.