#!/bin/sh # Shared helpers for Narratio's checked-in release scripts. This file is # intentionally source-only and has no effect when loaded. narratio_release_fail() { tool_name=$1 shift printf '%s: %s\n' "$tool_name" "$*" >&2 exit 1 } narratio_release_validate_version() { version=$1 case $version in v*.*.*) ;; *) return 1 ;; esac components=${version#v} if [ "$components" = "$version" ]; then return 1 fi previous_ifs=$IFS IFS=. set -- $components IFS=$previous_ifs if [ "$#" -ne 3 ]; then return 1 fi for component in "$@"; do case $component in 0 | [1-9]*) ;; *) return 1 ;; esac case $component in *[!0-9]*) return 1 ;; esac done } narratio_release_repo_root() ( script_path=$1 script_dir=$(CDPATH= cd "$(dirname "$script_path")" && pwd -P) || return 1 CDPATH= cd "$script_dir/.." && pwd -P )