| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | set -euo pipefail |
| 4 | |
| 5 | RED='\033[0;31m' |
| 6 | YELLOW='\033[1;33m' |
| 7 | GRAY='\033[0;90m' |
| 8 | NC='\033[0m' |
| 9 | |
| 10 | run() { |
| 11 | printf >&2 "${GRAY}%s >${NC} " "$(pwd)" |
| 12 | printf >&2 "${YELLOW}" |
| 13 | printf >&2 "%q " "$@" |
| 14 | printf >&2 "${NC}\n" |
| 15 | |
| 16 | if "$@"; then |
| 17 | return 0 |
| 18 | else |
| 19 | local exit_code=$? |
| 20 | echo -e >&2 "${RED}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" |
| 21 | echo -e >&2 "${RED}[ERROR]${NC} Command failed with exit code ${exit_code}: ${YELLOW}$1${NC}" |
| 22 | echo -e >&2 "${RED} Full command:${NC} $*" |
| 23 | echo -e >&2 "${RED} Working dir:${NC} $(pwd)" |
| 24 | echo -e >&2 "${RED}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" |
| 25 | return "${exit_code}" |
| 26 | fi |
| 27 | } |
| 28 | |
| 29 | SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" |
| 30 | REPO_ROOT="$(cd -- "${SCRIPT_DIR}/../../../.." && pwd)" |
| 31 | OUTPUT_DIR="${1:-${REPO_ROOT}/artifacts/topology-ip-intel-stock}" |
| 32 | PREPARE_SCRIPT="${REPO_ROOT}/.github/scripts/prepare-topology-ip-intel-stock.sh" |
| 33 | if [[ "${OUTPUT_DIR}" != /* ]]; then |
| 34 | OUTPUT_DIR="$(pwd)/${OUTPUT_DIR}" |
| 35 | fi |
| 36 | |
| 37 | run mkdir -p "${OUTPUT_DIR}" |
| 38 | cd "${REPO_ROOT}" |
| 39 | run "${PREPARE_SCRIPT}" --mode release --output-dir "${OUTPUT_DIR}" |