Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:

- name: Install Stellar CLI
if: steps.stellar-cli-cache.outputs.cache-hit != 'true'
uses: stellar/stellar-cli@v27.0.0
run: bash scripts/install-stellar-cli.sh 27.0.0

# The install action puts ~/.local/bin on PATH itself; on a cache hit it is
# skipped, so add the directory here too.
Expand Down Expand Up @@ -106,9 +106,7 @@ jobs:

- name: Install Stellar CLI ${{ matrix.stellar-version }}
if: steps.stellar-cli-cache.outputs.cache-hit != 'true'
uses: stellar/stellar-cli@v27.0.0
with:
version: ${{ matrix.stellar-version }}
run: bash scripts/install-stellar-cli.sh ${{ matrix.stellar-version }}

- name: Add Stellar CLI to PATH
run: echo "$HOME/.local/bin" >> "$GITHUB_PATH"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/testnet-deploy-regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:

- name: Install Stellar CLI
if: steps.stellar-cli-cache.outputs.cache-hit != 'true'
uses: stellar/stellar-cli@v27.0.0
run: bash scripts/install-stellar-cli.sh 27.0.0

# The install action puts ~/.local/bin on PATH itself; on a cache hit it is
# skipped, so add the directory here too.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/testnet-smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:

- name: Install Stellar CLI
if: steps.stellar-cli-cache.outputs.cache-hit != 'true'
uses: stellar/stellar-cli@v27.0.0
run: bash scripts/install-stellar-cli.sh 27.0.0

# The install action puts ~/.local/bin on PATH itself; on a cache hit it is
# skipped, so add the directory here too.
Expand Down
50 changes: 50 additions & 0 deletions scripts/install-stellar-cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash
# Install the Stellar CLI release binary with a resilient download.
#
# The official `stellar/stellar-cli` action only retries the CDN download a
# handful of times over ~25s, which a multi-minute 503 outage from the GitHub
# releases CDN can still blow past (see issue #119). When the binary is not
# already restored from `actions/cache`, this helper performs the same
# download with an exponential backoff that rides out much longer outages.
#
# Usage: install-stellar-cli.sh <version> [os-arch-triple]
# version CLI version, with or without a leading "v" (e.g. 27.0.0)
# os-arch-triple target triple (default: x86_64-unknown-linux-gnu)
set -euo pipefail

version_raw="${1:?Usage: install-stellar-cli.sh <version> [os-arch-triple]}"
os_arch="${2:-x86_64-unknown-linux-gnu}"

version="${version_raw#v}"
install_dir="$HOME/.local/bin"
mkdir -p "$install_dir"

file="stellar-cli-${version}-${os_arch}.tar.gz"
url="https://github.com/stellar/stellar-cli/releases/download/v${version}/${file}"

temp_dir="$(mktemp -d)"
trap 'rm -rf "$temp_dir"' EXIT

archive_path="${temp_dir}/${file}"

# Exponential backoff: 10s, 20s, 40s, 80s, 160s => ~5min of retries.
max_attempts=6
delay=10

attempt=1
until curl -fSL --retry 0 "$url" -o "$archive_path"; do
if (( attempt >= max_attempts )); then
echo "error: failed to download ${url} after ${max_attempts} attempts" >&2
exit 1
fi
echo "warning: download of ${url} failed (attempt ${attempt}); retrying in ${delay}s" >&2
sleep "$delay"
delay=$(( delay * 2 ))
attempt=$(( attempt + 1 ))
done

tar xzf "$archive_path" -C "$install_dir"
chmod +x "${install_dir}/stellar"

binary="${install_dir}/stellar"
"${binary}" --version