diff --git a/docs/build-cli-usage.sh b/docs/build-cli-usage.sh index dc767c638c..ce5f582fa3 100755 --- a/docs/build-cli-usage.sh +++ b/docs/build-cli-usage.sh @@ -3,6 +3,29 @@ set -e cd "$(dirname "$0")" +# shellcheck source=ci/env.sh +source ../ci/env.sh + +# Get current channel +eval "$(../ci/channel-info.sh)" + +# set the output file' location +out=${1:-src/cli/usage.md} + +# load the usage file's header +cat src/cli/.usage.md.header > "$out" + +# Skip generating the usage doc for non deployment commits of the docs +if [[ -n $CI ]]; then + if [[ $CI_BRANCH != $EDGE_CHANNEL* ]] && [[ $CI_BRANCH != $BETA_CHANNEL* ]] && [[ $CI_BRANCH != $STABLE_CHANNEL* ]]; then + echo "**NOTE:** The usage doc is only auto-generated during full production deployments of the docs" + echo "**NOTE:** This usage doc is auto-generated during deployments" >> "$out" + exit + fi +fi + +echo 'Building the solana cli from source...' + # shellcheck source=ci/rust-version.sh source ../ci/rust-version.sh stable @@ -13,10 +36,6 @@ cargo build -p solana-cli usage=$(cargo -q run -p solana-cli -- -C ~/.foo --help | sed -e 's|'"$HOME"'|~|g' -e 's/[[:space:]]\+$//') -out=${1:-src/cli/usage.md} - -cat src/cli/.usage.md.header > "$out" - section() { declare mark=${2:-"###"} declare section=$1