#!/bin/bash
#
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
#

set -eux

STABLE_SEMANTIC_VERSION="${1}"
UNSTABLE_SEMANTIC_VERSION="${2}"
SMITHY_RS_DIR="$(pwd)/smithy-rs"
ARTIFACTS_DIR="$(pwd)/artifacts/upgrade-gradle-properties"
mkdir -p "${ARTIFACTS_DIR}"

pushd "${SMITHY_RS_DIR}"
echo "gradle.properties BEFORE the upgrade"
cat gradle.properties
publisher upgrade-runtime-crates-version --stable-version "${STABLE_SEMANTIC_VERSION}" --version "${UNSTABLE_SEMANTIC_VERSION}"
echo "gradle.properties AFTER the upgrade"
cat gradle.properties
git status
popd

pushd "${ARTIFACTS_DIR}"
mkdir -p smithy-rs
cp -r "${SMITHY_RS_DIR}" .
git -C smithy-rs status
popd
