#!/usr/bin/env sh

set +x

if [ "$#" -ne 4 ]; then
    echo "You need to provide the old version and the new one for both the semver and android release number"
    echo "E.g. create-release 1.0 1.1 4 5"
    exit 1
fi

make test format-frontend

OLD_VERSION=$1
NEW_VERSION=$2
OLD_NUMBER=$3
NEW_NUMBER=$4

sed -i "s/${OLD_VERSION}/${NEW_VERSION}/g" android-files/* tauri.conf.json Cargo.toml
sed -i "s/${OLD_NUMBER}/${NEW_NUMBER}/g" android-files/* tauri.conf.json

glab changelog generate --version "$NEW_VERSION" > fastlane/metadata/android/en-US/changelogs/${NEW_NUMBER}.txt
