ci: use previous version to raise proposal (#948) #585
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create release | |
on: | |
push: | |
tags: | |
- v* | |
permissions: | |
contents: write | |
jobs: | |
release: | |
name: Create release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.event.inputs.release_tag }} | |
- name: Make release | |
run: | | |
sudo rm -rf dist | |
make release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create software upgrade proposal | |
run: | | |
# 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]+900; exit }'; } | |
extract_checksum() { awk "/elysd-${{ github.ref_name }}-linux-amd64.tar.gz/ {print \$1; exit}"; } | |
# environment variables | |
ELYSD=dist/elysd-linux-amd64_linux_amd64_v1/elysd | |
NODE=https://rpc.testnet.elys.network:443 | |
OPTIONS="--node $NODE --chain-id elystestnet-1 --keyring-backend=test -b=sync --fees=100000uelys --gas=300000 -y" | |
# TODO: remove this block after the next release | |
OLD_VERSION=v0.49.4 | |
DOWNLOAD_URL=https://github.com/elys-network/elys/releases/download/${OLD_VERSION}/elysd-${OLD_VERSION}-linux-amd64 | |
OLD_BINARY_PATH=/tmp/elysd-${OLD_VERSION} | |
# download binary from release | |
curl -L $DOWNLOAD_URL -o ${OLD_BINARY_PATH} && chmod +x ${OLD_BINARY_PATH} | |
# save private keys to files | |
echo "${{ secrets.PRIVATE_KEY_1 }}" > /tmp/private_key_1.txt | |
echo "${{ secrets.PRIVATE_KEY_2 }}" > /tmp/private_key_2.txt | |
echo "${{ secrets.PRIVATE_KEY_3 }}" > /tmp/private_key_3.txt | |
echo "${{ secrets.PRIVATE_KEY_4 }}" > /tmp/private_key_4.txt | |
# recover keys | |
echo "${{ secrets.PASSPHRASE_1 }}" | ${OLD_BINARY_PATH} keys import key_1 --keyring-backend test /tmp/private_key_1.txt | |
echo "${{ secrets.PASSPHRASE_2 }}" | ${OLD_BINARY_PATH} keys import key_2 --keyring-backend test /tmp/private_key_2.txt | |
echo "${{ secrets.PASSPHRASE_3 }}" | ${OLD_BINARY_PATH} keys import key_3 --keyring-backend test /tmp/private_key_3.txt | |
echo "${{ secrets.PASSPHRASE_4 }}" | ${OLD_BINARY_PATH} keys import key_4 --keyring-backend test /tmp/private_key_4.txt | |
# get checksum | |
checksum=$(cat dist/sha256sum.txt | extract_checksum) | |
# query and upgrade height | |
height=$(${OLD_BINARY_PATH} status --node $NODE | extract_and_calc_upgrade_height) | |
# create proposal | |
txhash=$( | |
${OLD_BINARY_PATH} tx gov submit-legacy-proposal software-upgrade \ | |
${{ github.ref_name }} \ | |
--deposit=10000000uelys \ | |
--upgrade-height=$height \ | |
--title="${{ github.ref_name }}" \ | |
--description="Elys Network ${{ github.ref_name }} released. Focuses on enhancements and codebase improvements." \ | |
--upgrade-info="{\"binaries\":{\"linux/amd64\":\"https://github.com/elys-network/elys/releases/download/${{ github.ref_name }}/elysd-${{ github.ref_name }}-linux-amd64.tar.gz?checksum=$checksum\"}}" \ | |
--no-validate \ | |
--from=key_1 \ | |
$OPTIONS | extract_txhash | |
) | |
sleep 10 | |
proposalid=$(${OLD_BINARY_PATH} q tx $txhash --node $NODE | extract_proposal_id) | |
# vote on proposal | |
${OLD_BINARY_PATH} tx gov vote $proposalid yes --from=key_1 $OPTIONS | |
${OLD_BINARY_PATH} tx gov vote $proposalid yes --from=key_2 $OPTIONS | |
${OLD_BINARY_PATH} tx gov vote $proposalid yes --from=key_3 $OPTIONS | |
${OLD_BINARY_PATH} tx gov vote $proposalid yes --from=key_4 $OPTIONS | |
sleep 10 |