From 1bf81d7b0fc7b54cd688edf7f3f61e6d7a06d06a Mon Sep 17 00:00:00 2001 From: Cosmic Vagabond <121588426+cosmic-vagabond@users.noreply.github.com> Date: Mon, 16 Dec 2024 19:01:23 +0100 Subject: [PATCH] Add deployment workflow for MainNet (#1062) * Add deployment workflow for MainNet - Added a MainNet deployment workflow that retrieves the latest release version and creates a software upgrade proposal. * chore: update next version --- .../{deploy.yml => devnet-deploy.yml} | 13 ++--- .github/workflows/mainnet-deploy.yml | 56 +++++++++++++++++++ ...ase.yml => release-and-testnet-deploy.yml} | 4 +- app/setup_handlers.go | 2 +- 4 files changed, 64 insertions(+), 11 deletions(-) rename .github/workflows/{deploy.yml => devnet-deploy.yml} (95%) create mode 100644 .github/workflows/mainnet-deploy.yml rename .github/workflows/{release.yml => release-and-testnet-deploy.yml} (97%) diff --git a/.github/workflows/deploy.yml b/.github/workflows/devnet-deploy.yml similarity index 95% rename from .github/workflows/deploy.yml rename to .github/workflows/devnet-deploy.yml index a628bd3e0..28ae00e4d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/devnet-deploy.yml @@ -1,16 +1,13 @@ -name: Deploy in devnet +name: DevNet deploy on: workflow_dispatch: - # push: - # branches: - # - main jobs: deploy: runs-on: ubuntu-latest concurrency: - group: deploy-devnet # Group for limiting concurrent runs - cancel-in-progress: false # Queue new jobs instead of canceling if one is already running + group: deploy-devnet # Group for limiting concurrent runs + cancel-in-progress: false # Queue new jobs instead of canceling if one is already running environment: devnet env: BRANCH_NAME: ${{ github.head_ref || github.ref_name }} @@ -100,7 +97,7 @@ jobs: echo "${{ secrets.PRIVATE_KEY_FUJI }}" > /tmp/private_key_fuji.txt echo "${{ secrets.PRIVATE_KEY_MALLORCA }}" > /tmp/private_key_mallorca.txt echo "${{ secrets.PRIVATE_KEY_BORA }}" > /tmp/private_key_bora.txt - + # recover keys echo "${{ secrets.PASSPHRASE_FUJI }}" | $ELYSD keys import fuji --keyring-backend test /tmp/private_key_fuji.txt echo "${{ secrets.PASSPHRASE_MALLORCA }}" | $ELYSD keys import mallorca --keyring-backend test /tmp/private_key_mallorca.txt @@ -135,4 +132,4 @@ jobs: $ELYSD tx gov vote $proposalid yes --from=fuji $OPTIONS $ELYSD tx gov vote $proposalid yes --from=mallorca $OPTIONS $ELYSD tx gov vote $proposalid yes --from=bora $OPTIONS - sleep 10 \ No newline at end of file + sleep 10 diff --git a/.github/workflows/mainnet-deploy.yml b/.github/workflows/mainnet-deploy.yml new file mode 100644 index 000000000..c0cae5681 --- /dev/null +++ b/.github/workflows/mainnet-deploy.yml @@ -0,0 +1,56 @@ +name: MainNet deploy + +on: + workflow_dispatch: + +permissions: + contents: write + +jobs: + release: + name: Deploy to MainNet + 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_URL=https://github.com/elys-network/elys/releases/download/${ELYS_VERSION}/elysd-${ELYS_VERSION}-linux-amd64 + ELYSD=/tmp/elysd-${ELYS_VERSION} + curl -L $DOWNLOAD_URL -o $ELYSD && chmod +x $ELYSD + + # 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 }} + + # get checksum + checksum=$(cat dist/sha256sum.txt | 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 \ + 0uelys \ + "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\"}}" \ + --from=proposer \ + $OPTIONS | extract_txhash + ) + sleep 10 + proposalid=$(${ELYSD} q tx $txhash --node $NODE | extract_proposal_id) diff --git a/.github/workflows/release.yml b/.github/workflows/release-and-testnet-deploy.yml similarity index 97% rename from .github/workflows/release.yml rename to .github/workflows/release-and-testnet-deploy.yml index 5740b78ca..6fe3bfc72 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release-and-testnet-deploy.yml @@ -1,4 +1,4 @@ -name: Create release +name: Create release and TestNet deploy on: push: @@ -10,7 +10,7 @@ permissions: jobs: release: - name: Create release + name: Create release and TestNet deploy runs-on: ubuntu-latest steps: - name: Check out repository code diff --git a/app/setup_handlers.go b/app/setup_handlers.go index a929e7114..9405f76e4 100644 --- a/app/setup_handlers.go +++ b/app/setup_handlers.go @@ -19,7 +19,7 @@ const ( ) // make sure to update these when you upgrade the version -var NextVersion = "v1.0.1" +var NextVersion = "v1.1.0" func (app *ElysApp) setUpgradeHandler() { app.UpgradeKeeper.SetUpgradeHandler(