#!/usr/bin/env bash

if [[ ! "$1" ]]; then
  printf "%s\n" "Usage: $0 <hg tag>" "Example: $0 4.0.10"
  exit
fi

hg update "$1"
tools/generateReleaseInfo
mkdir rawtherapee-"$1"
mv ReleaseInfo.cmake rawtherapee-"$1"
hg archive -X ".hg*" -X "rtgui/config.h" -X "rtgui/version.h" -X "rtdata/rawtherapee.desktop" rawtherapee-"$1".tar
tar -rf rawtherapee-"$1".tar rawtherapee-"$1"/ReleaseInfo.cmake
xz -z -9e rawtherapee-"$1".tar
rm -r rawtherapee-"$1"
hg update
