-
Notifications
You must be signed in to change notification settings - Fork 55
137 lines (126 loc) · 5.87 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: Deploy in devnet
on:
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
environment: devnet
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
NAME: elys
COMMIT: ${{ github.sha }}
VERSION:
BINARY:
DBENGINE: pebbledb
NAME_WITH_VERSION:
steps:
- name: Checking repository
uses: actions/checkout@v4
- name: Setting variables
run: |
VER=v${{ github.sha }}
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.22"
- name: Building elys binary
run: |
echo Building elysd binary
sudo GOOS=linux GOARCH=amd64 CGO_ENABLED=0 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/elys-network/elys/app.NextVersion=${VERSION} \
-X github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger,osusergo,${DBENGINE} \
" -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: Backup Devnet
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
passphrase: ${{ secrets.SSH_PASSPHRASE }}
script: /bin/bash /home/ubuntu/ci-cd-devnet-backup-and-rollback/backup.sh
command_timeout: 60m
- 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
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
echo "${{ secrets.PASSPHRASE_BORA }}" | $ELYSD keys import bora --keyring-backend test /tmp/private_key_bora.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 software-upgrade-tx \
${{env.VERSION}} \
$height \
10000000uelys \
"Elys Network version ${{env.VERSION}} released. Focuses on enhancements and codebase improvements." \
"{\"binaries\":{\"linux/amd64\":\"https://snapshots.elys.network/releases/${{env.NAME_WITH_VERSION}}.tar.gz\"}}" \
--from=mallorca \
$OPTIONS | extract_txhash
)
sleep 10
#Tx Hash
echo "software upgrade tx hash:" $txhash
proposalid=$($ELYSD q tx $txhash --node $NODE | extract_proposal_id)
#Proposal Id
echo "Proposal Id:" $proposalid
# vote on proposal
$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