Fix APR calculation (#574) (#575) #5
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: Deploy in devnet | |
on: | |
push: | |
branches: | |
- devnet | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
environment: devnet | |
env: | |
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
NAME: elys | |
COMMIT: ${{ github.sha }} | |
VERSION: | |
BINARY: | |
DBENGINE: pebbledb | |
COSMWASM_VERSION: | |
NAME_WITH_VERSION: | |
steps: | |
- name: Checking repository | |
uses: actions/checkout@v4 | |
- name: Setting variables | |
run: | | |
VER=$(cat .version) | |
echo "VERSION=$VER" >> $GITHUB_ENV | |
echo "BINARY=${NAME}d" >> $GITHUB_ENV | |
echo "NAME_WITH_VERSION=${NAME}-${VER}" >> $GITHUB_ENV | |
- name: Debuging enviroment | |
run: | | |
echo "BRANCH NAME:" $BRANCH_NAME | |
echo "NAME:" $NAME | |
echo "COMMIT:" $COMMIT | |
echo "VERSION": $VERSION | |
echo "BYNARY": $BINARY | |
echo "NAME_WITH_VERSION": $NAME_WITH_VERSION | |
- name: Setuping go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: "1.21" | |
- name: Building elys binary | |
env: | |
CGO_ENABLED: 1 | |
run: | | |
echo Building elysd binary | |
COSMWASM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | sed 's/.* //') | |
echo $COSMWASM_VERSION | |
sudo wget https://github.com/CosmWasm/wasmvm/releases/download/${COSMWASM_VERSION}/libwasmvm_muslc.x86_64.a -O /usr/lib/libwasmvm.x86_64.a | |
sudo GOOS=linux GOARCH=amd64 go build -mod=readonly -trimpath -o elysd -ldflags "-X github.com/cosmos/cosmos-sdk/version.Name=${NAME} \ | |
-X github.com/cosmos/cosmos-sdk/version.AppName=${NAME} \ | |
-X github.com/cosmos/cosmos-sdk/version.ServerName=${BINARY} \ | |
-X github.com/cosmos/cosmos-sdk/version.ClientName=${BINARY} \ | |
-X github.com/cosmos/cosmos-sdk/version.Version=${VERSION} \ | |
-X github.com/cosmos/cosmos-sdk/version.Commit=${COMMIT} \ | |
-X github.com/cosmos/cosmos-sdk/types.DBBackend=${DBENGINE} \ | |
-X github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger,muslc,osusergo,${DBENGINE} \ | |
-w -s \ | |
-linkmode=external \ | |
-extldflags '-Wl,-z,muldefs -static -lm'" -tags "ledger,${DBENGINE}" ./cmd/${BINARY} | |
echo "Version of elysd: $(./elysd version)" | |
- name: Compressing elys binary | |
run: | | |
cp elysd /tmp/elysd | |
sudo apt-get install -y tar | |
tar czvf ${{env.NAME_WITH_VERSION}}.tar.gz elysd | |
mkdir -p ${{env.NAME_WITH_VERSION}} | |
mv ${{env.NAME_WITH_VERSION}}.tar.gz ${{env.NAME_WITH_VERSION}}/${{env.NAME_WITH_VERSION}}.tar.gz | |
- uses: ryand56/r2-upload-action@latest | |
id: bucket | |
name: Uploading binary to bucket | |
with: | |
r2-account-id: ${{ secrets.R2_ACCOUNT_ID }} | |
r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }} | |
r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }} | |
r2-bucket: ${{ secrets.R2_BUCKET }} | |
source-dir: ${{env.NAME_WITH_VERSION}} | |
destination-dir: releases | |
- name: Creating 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]+25; exit }'; } | |
extract_checksum() { awk "/elysd-${{ github.ref_name }}-linux-amd64.tar.gz/ {print \$1; exit}"; } | |
# environment variables | |
ELYSD=/tmp/elysd | |
NODE=https://rpc.devnet.elys.network:443 | |
OPTIONS="--node $NODE --chain-id elysdevnet-1 --keyring-backend=test -b=sync --fees=100000uelys --gas=300000 -y" | |
# save private keys to files | |
echo "${{ secrets.PRIVATE_KEY_FUJI }}" > /tmp/private_key_fuji.txt | |
echo "${{ secrets.PRIVATE_KEY_MALLORCA }}" > /tmp/private_key_mallorca.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 | |
# 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 tx gov submit-legacy-proposal software-upgrade \ | |
${{env.VERSION}} \ | |
--deposit=10000000uelys \ | |
--upgrade-height=$height \ | |
--title="${{env.VERSION}}" \ | |
--description="Elys Network${{env.VERSION}} released. Focuses on enhancements and codebase improvements." \ | |
--upgrade-info="{\"binaries\":{\"linux/amd64\":\"https://snapshots.elys.network/releases/${{env.NAME_WITH_VERSION}}.tar.gz\"}}" \ | |
--no-validate \ | |
--from=mallorca \ | |
$OPTIONS | extract_txhash | |
) | |
sleep 10 | |
proposalid=$($ELYSD q tx $txhash --node $NODE | extract_proposal_id) | |
# vote on proposal | |
$ELYSD tx gov vote $proposalid yes --from=fuji $OPTIONS | |
$ELYSD tx gov vote $proposalid yes --from=mallorca $OPTIONS | |
sleep 10 |