Skip to main content

scripts/ci/sku-validate.sh

Metadata

Indexed Symbols

No indexed functions/methods detected in this file.

Markdown Headings (if applicable)

No markdown headings detected.

Source Preview

#!/usr/bin/env bash
set -euo pipefail

VERSION_FILE=${1:-version.txt}
SKU_REGEX='^[0-9]+\.[0-9]+\.[0-9]+\.[A-Z0-9]+\.[A-Z0-9]+\.[0-9]{8}$'

if [[ ! -f "${VERSION_FILE}" ]]; then
echo "Missing ${VERSION_FILE}"
exit 1
fi

SKU=$(tr -d '[:space:]' < "${VERSION_FILE}")
if [[ -z "${SKU}" ]]; then
echo "SKU is empty in ${VERSION_FILE}"
exit 1
fi

if [[ ! "${SKU}" =~ ${SKU_REGEX} ]]; then
echo "Invalid SKU '${SKU}'. Expected VERSION.TYPE.PLATFORM.DATE"
exit 1
fi

echo "SKU validated: ${SKU}"