#!/usr/bin/env bash # Print the next build version, YYYYMMDD.NN: today's date in the household's # time zone, then a counter that starts at .01 each day. # # Reads the last version from the VERSION file (or $1). Set TODAY=YYYYMMDD to # pretend it's another day, which the tests use. set -euo pipefail cd "$(dirname "$0")/.." previous="${1:-$(cat VERSION 2>/dev/null || true)}" today="${TODAY:-$(TZ="${TZ:-America/New_York}" date +%Y%m%d)}" if [[ "$previous" =~ ^${today}\.([0-9]+)$ ]]; then counter=$((10#${BASH_REMATCH[1]} + 1)) else counter=1 fi printf '%s.%02d\n' "$today" "$counter"