From 25e47aa5ec9fd687abb37f6edfe78233ddec64cb Mon Sep 17 00:00:00 2001 From: Nabarun Date: Fri, 17 May 2024 10:56:26 +0530 Subject: [PATCH] Add deployment script for staging --- packages/deployer/config.staging.yml | 9 ++ packages/deployer/deploy-frontend.staging.sh | 95 ++++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 packages/deployer/config.staging.yml create mode 100755 packages/deployer/deploy-frontend.staging.sh diff --git a/packages/deployer/config.staging.yml b/packages/deployer/config.staging.yml new file mode 100644 index 0000000..c659d5d --- /dev/null +++ b/packages/deployer/config.staging.yml @@ -0,0 +1,9 @@ +services: + cns: + restEndpoint: 'http://console.laconic.com:1317' + gqlEndpoint: 'http://console.laconic.com:9473/api' + userKey: 87d00f66a73e2ca428adeb49ba9164d0ad9a87edc60e33d46ad3031b9c5701fe + bondId: 098c906850b87412f02200e41f449bc79e055eab77acfef32c0b22443bb46661 + chainId: laconic_9000-1 + gas: 550000 + fees: 200000aphoton diff --git a/packages/deployer/deploy-frontend.staging.sh b/packages/deployer/deploy-frontend.staging.sh new file mode 100755 index 0000000..e3c89a8 --- /dev/null +++ b/packages/deployer/deploy-frontend.staging.sh @@ -0,0 +1,95 @@ +#!/bin/bash + +# Repository URL +REPO_URL="https://git.vdb.to/cerc-io/snowballtools-base" + +# Get the latest commit hash from the repository +LATEST_HASH=$(git ls-remote $REPO_URL HEAD | awk '{print $1}') + +# Extract version from ../frontend/package.json +PACKAGE_VERSION=$(jq -r '.version' ../frontend/package.json) + +# Current date and time for note +CURRENT_DATE_TIME=$(date -u) + +CONFIG_FILE=config.staging.yml +REGISTRY_BOND_ID="098c906850b87412f02200e41f449bc79e055eab77acfef32c0b22443bb46661" + +# Reference: https://git.vdb.to/cerc-io/test-progressive-web-app/src/branch/main/scripts + +# Get latest version from registry and increment application-record version +NEW_APPLICATION_VERSION=$(yarn --silent laconic -c $CONFIG_FILE cns record list --type ApplicationRecord --all --name "staging-snowballtools-base-frontend" 2>/dev/null | jq -r -s ".[] | sort_by(.createTime) | reverse | [ .[] | select(.bondId == \"$REGISTRY_BOND_ID\") ] | .[0].attributes.version" | awk -F. -v OFS=. '{$NF += 1 ; print}') + +if [ -z "$NEW_APPLICATION_VERSION" ] || [ "1" == "$NEW_APPLICATION_VERSION" ]; then + # Set application-record version if no previous records were found + NEW_APPLICATION_VERSION=0.0.1 +fi + +# Generate application-deployment-request.yml +cat > ./staging-records/application-deployment-request.yml < ./staging-records/application-record.yml <