handheld-daemon-ui: 3.2.3 -> 3.3.0 (#361609)
[NixPkgs.git] / pkgs / development / tools / sauce-connect / update.sh
blob1c6f10b33046a3dffa4104b3b9821e353bf31c31
1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p common-updater-scripts curl jq
3 # API documentation: https://docs.saucelabs.com/dev/api/connect/
5 set -Eeuo pipefail
6 shopt -s lastpipe
7 die() {
8 echo -e "${BASH_SOURCE[0]}:${BASH_LINENO[0]}" ERROR: "$@" >&2
9 exit 1
11 # shellcheck disable=2154
12 trap 's=$?; die "$BASH_COMMAND"; exit $s' ERR
14 # Versions may not be updated simultaneously across all platforms, so need to figure out the latest
15 # version that includes both platforms. For example, currently the latest on Linux is 4.9.2 while
16 # Mac is 4.9.1.
17 response=$(curl -fsSL 'https://api.us-west-1.saucelabs.com/rest/v1/public/tunnels/info/versions?all=true')
18 all_versions=$(jq --exit-status --raw-output \
19 '.all_downloads | to_entries[] | select(.value | has("linux") and has("osx")) | .key' \
20 <<< "$response")
21 latest_version=$(sort --version-sort <<< "$all_versions" | tail -n 1)
22 for platform in x86_64-linux x86_64-darwin; do
23 update-source-version sauce-connect "$latest_version" \
24 --ignore-same-version \
25 --source-key="passthru.sources.$platform"
26 done