#!/bin/bash # compose: no-hooks upstream_version="$1" version="${upstream_version/./}" read -r year_month major minor patch <<< ${version//./ } if ! [ "${#patch}" == 1 ]; then echo "Error: build number is not a single digit: '${patch}' (upstream: '${upstream_version}')" >&2 exit 1 fi if [ "${#major}" -gt 2 ]; then echo "Error: major number is more than 2 digits: '${major}' (upstream: '${upstream_version}')" >&2 exit 1 fi major=$(printf "%02d" ${major}) echo "${year_month}${major}.${minor}.${patch}"