From 323144ac565bac4fa066b34a020dc84c9734d84b Mon Sep 17 00:00:00 2001 From: Cosmic Vagabond <121588426+cosmic-vagabond@users.noreply.github.com> Date: Thu, 19 Dec 2024 22:03:39 +0100 Subject: [PATCH] ci: update mainnet deploy workflows (#1074) --- ...innet-deploy.yml => mainnet-deploy-2h.yml} | 10 ++- .github/workflows/mainnet-deploy-48h.yml | 64 +++++++++++++++++++ 2 files changed, 71 insertions(+), 3 deletions(-) rename .github/workflows/{mainnet-deploy.yml => mainnet-deploy-2h.yml} (93%) create mode 100644 .github/workflows/mainnet-deploy-48h.yml diff --git a/.github/workflows/mainnet-deploy.yml b/.github/workflows/mainnet-deploy-2h.yml similarity index 93% rename from .github/workflows/mainnet-deploy.yml rename to .github/workflows/mainnet-deploy-2h.yml index bd507de6c..0f5a33712 100644 --- a/.github/workflows/mainnet-deploy.yml +++ b/.github/workflows/mainnet-deploy-2h.yml @@ -1,4 +1,4 @@ -name: MainNet deploy +name: MainNet deploy in 2 hours on: workflow_dispatch: @@ -8,7 +8,7 @@ permissions: jobs: release: - name: Deploy to MainNet + name: Deploy to MainNet in 2 hours runs-on: ubuntu-latest steps: - name: Create software upgrade proposal @@ -49,12 +49,16 @@ jobs: ${ELYSD} software-upgrade-tx \ ${ELYS_VERSION} \ $height \ - 0uelys \ + 5000000000uelys \ "Elys Network ${ELYS_VERSION} released. Focuses on enhancements and codebase improvements." \ "{\"binaries\":{\"linux/amd64\":\"https://github.com/elys-network/elys/releases/download/${ELYS_VERSION}/elysd-${ELYS_VERSION}-linux-amd64.tar.gz?checksum=$checksum\"}}" \ true \ --from=proposer \ $OPTIONS | extract_txhash ) + echo "txhash: $txhash" + sleep 10 + proposalid=$(${ELYSD} q tx $txhash --node $NODE | extract_proposal_id) + echo "proposalid: $proposalid" diff --git a/.github/workflows/mainnet-deploy-48h.yml b/.github/workflows/mainnet-deploy-48h.yml new file mode 100644 index 000000000..52688a237 --- /dev/null +++ b/.github/workflows/mainnet-deploy-48h.yml @@ -0,0 +1,64 @@ +name: MainNet deploy in 48 hours + +on: + workflow_dispatch: + +permissions: + contents: write + +jobs: + release: + name: Deploy to MainNet in 48 hours + runs-on: ubuntu-latest + steps: + - name: Create software upgrade proposal + run: | + # Get latest release version using GitHub API + ELYS_VERSION=$(curl -s https://api.github.com/repos/elys-network/elys/releases/latest | grep -Po '"tag_name": "\K.*?(?=")') + echo "Latest elys version: $ELYS_VERSION" + + # Download latest binary + DOWNLOAD_BINARY_URL=https://github.com/elys-network/elys/releases/download/${ELYS_VERSION}/elysd-${ELYS_VERSION}-linux-amd64 + DOWNLOAD_SHA256_URL=https://github.com/elys-network/elys/releases/download/${ELYS_VERSION}/sha256sum.txt + ELYSD=/tmp/elysd-${ELYS_VERSION} + SHA256SUM=/tmp/sha256sum.txt + curl -L $DOWNLOAD_BINARY_URL -o $ELYSD && chmod +x $ELYSD + curl -L $DOWNLOAD_SHA256_URL -o $SHA256SUM + + # helper functions + extract_txhash() { awk -F 'txhash: ' '/txhash:/{print $2; exit}'; } + extract_proposal_id() { awk -F 'key: proposal_id|value: ' '/key: proposal_id/ { getline; gsub(/"/, "", $2); print $2; exit }'; } + extract_and_calc_upgrade_height() { awk -F'"latest_block_height":"' '{ split($2,a,"\""); print a[1]+2100; exit }'; } + extract_checksum() { awk "/elysd-${ELYS_VERSION}-linux-amd64.tar.gz/ {print \$1; exit}"; } + + # environment variables + NODE=https://rpc.elys.network:443 + OPTIONS="--node $NODE --chain-id elys-1 --keyring-backend=test -b=sync --fees=100000uelys --gas=300000 -y" + + # import proposer key + ${ELYSD} keys import-hex proposer ${{ secrets.MAINNET_PROPOSER_PRIVATE_KEY }} --keyring-backend=test + + # get checksum + checksum=$(cat $SHA256SUM | extract_checksum) + + # query and upgrade height + height=$(${ELYSD} status --node $NODE | extract_and_calc_upgrade_height) + + # create proposal + txhash=$( + ${ELYSD} software-upgrade-tx \ + ${ELYS_VERSION} \ + $height \ + 1000000000uelys \ + "Elys Network ${ELYS_VERSION} released. Focuses on enhancements and codebase improvements." \ + "{\"binaries\":{\"linux/amd64\":\"https://github.com/elys-network/elys/releases/download/${ELYS_VERSION}/elysd-${ELYS_VERSION}-linux-amd64.tar.gz?checksum=$checksum\"}}" \ + false \ + --from=proposer \ + $OPTIONS | extract_txhash + ) + echo "txhash: $txhash" + + sleep 10 + + proposalid=$(${ELYSD} q tx $txhash --node $NODE | extract_proposal_id) + echo "proposalid: $proposalid"