#!/usr/bin/env bash set -euo pipefail project_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd) output_dir=${1:?usage: package.sh OUTPUT_DIR IMAGE_TAG [VERSION_SUFFIX]} image_tag=${2:?IMAGE_TAG is required} suffix=${3:-} base_version=$(<"${project_dir}/chart-version.txt") [[ "${base_version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "chart-version.txt must contain a three-part numeric version" >&2 exit 1 } [[ "${image_tag}" =~ ^[A-Za-z0-9][A-Za-z0-9_.-]*$ ]] || { echo "Invalid image tag" >&2 exit 1 } version=${base_version} if [[ -n "${suffix}" ]]; then [[ "${suffix}" =~ ^[A-Za-z0-9][A-Za-z0-9.-]*$ ]] || exit 1 version="${base_version}-${suffix}" fi mkdir -p -- "${output_dir}" helm package "${project_dir}" --destination "${output_dir}" \ --version "${version}" --app-version "${image_tag}" >/dev/null printf '%s/brave-sync-%s.tgz\n' "${output_dir%/}" "${version}"