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

set -eux

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

pushd "${SMITHY_RS_DIR}"
publisher upgrade-runtime-crates-version --version "${SEMANTIC_VERSION}"
popd

# Clone smithy-rs repo changes (changelog updates) into
# the `smithy-rs-release` artifact for push to GitHub
pushd "${ARTIFACTS_DIR}"
git clone "${SMITHY_RS_DIR}"
# Copy over the original remotes so that it's possible to push to `origin`
cp "${SMITHY_RS_DIR}/.git/config" smithy-rs/.git/config
popd
