#!/bin/bash # Repository URL REPO_URL="https://github.com/snowball-tools-platform/test-progressive-web-app" # Get the latest commit hash from the repository LATEST_HASH=$(git ls-remote $REPO_URL HEAD | awk '{print $1}') # Fetch the package.json file content # Extract version from package.json content package_json=$(wget -qO- "$REPO_URL/raw/$LATEST_HASH/package.json") PACKAGE_VERSION=$(echo "$package_json" | jq -r '.version') # Current date and time for note CURRENT_DATE_TIME=$(date -u) CONFIG_FILE=packages/deployer/config.yml REGISTRY_BOND_ID="99c0e9aec0ac1b8187faa579be3b54f93fafb6060ac1fd29170b860df605be32" # Reference: https://git.vdb.to/cerc-io/test-progressive-web-app/src/branch/main/scripts APP_NAME=deployment-test-app # 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 "$APP_NAME" 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-record.yml with incremented version RECORD_FILE=packages/deployer/test/records/application-record.yml cat > $RECORD_FILE < $REQUEST_RECORD_FILE < $REMOVAL_REQUEST_RECORD_FILE <