git config user.email "jonathan.franco.2103@gmail.com"
git config user.name "CI"
git remote remove ci
git remote add ci https://oauth2:"${PUBLISH_TOKEN}"@gitlab.com/rglw/public/apis/rglw_api.git
git checkout main
git reset --hard origin/main
cargo install toml-cli
ROOT=$(pwd)
DEPENDENCIES_VERSION=$(toml get Cargo.toml workspace.package.version --raw)
CODEGEN=${ROOT}/rglw_api_codegen
COMMON=${ROOT}/rglw_api_common
CORE=${ROOT}/rglw_api_core
cd "${CODEGEN}" || exit 1
cargo publish
cd "${COMMON}" || exit 1
toml set Cargo.toml dependencies.rglw_api_codegen.version "${DEPENDENCIES_VERSION}" > Cargo.toml.modified
mv Cargo.toml.modified Cargo.toml
cargo publish --allow-dirty
cd "${CORE}" || exit 1
toml set Cargo.toml dependencies.rglw_api_codegen.version "${DEPENDENCIES_VERSION}" > Cargo.toml.modified
mv Cargo.toml.modified Cargo.toml
toml set Cargo.toml dependencies.rglw_api_common.version "${DEPENDENCIES_VERSION}" > Cargo.toml.modified
mv Cargo.toml.modified Cargo.toml
cargo publish --allow-dirty
cd "${ROOT}" || exit 1
toml set Cargo.toml dependencies.rglw_api_codegen.version "${DEPENDENCIES_VERSION}" > Cargo.toml.modified
mv Cargo.toml.modified Cargo.toml
toml set Cargo.toml dependencies.rglw_api_common.version "${DEPENDENCIES_VERSION}" > Cargo.toml.modified
mv Cargo.toml.modified Cargo.toml
toml set Cargo.toml dependencies.rglw_api_core.version "${DEPENDENCIES_VERSION}" > Cargo.toml.modified
mv Cargo.toml.modified Cargo.toml
cargo publish --allow-dirty