forked from cosmos/chain-registry
-
Notifications
You must be signed in to change notification settings - Fork 0
206 lines (185 loc) · 7.07 KB
/
add_version.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
name: version add
on:
workflow_dispatch:
inputs:
chain:
description: "Chain to update"
required: true
default: ""
type: string
tag-height-proposal:
description: "Tag, Height and Proposal. If the upgrade is not consensus-breaking, leave height and proposal to -1."
required: true
default: '{
"tag": "-1",
"height": -1,
"proposal": -1
}'
type: string
cosmos_sdk_version:
description: "CosmosSDK version. Not required"
required: false
default: "0.46"
type: string
consensus:
description: "Consensus. Not required"
required: false
default: '{
"type": "tendermint",
"version": "0.34"
}'
type: string
cosmwasm_version:
description: "CosmWasm version. Not required"
required: false
default: ""
type: string
cosmwasm_path:
description: "Default path to wasm directory. Not required"
required: false
default: ""
type: string
ibc_go_version:
description: "IBC-go version. Not required"
required: false
default: ""
type: string
ics_enabled:
description: "List of enabled ICS. Not required"
required: false
default: '[]'
type: string
binaries:
description: "Binaries list. Enter a list of binaries in JSON format"
required: true
default: '{
"linux/amd64": "",
"linux/arm64": "",
"darwin/amd64": "",
"darwin/arm64": ""
}'
type: string
jobs:
validate_data:
name: Validate Data
runs-on: ubuntu-latest
outputs:
check: ${{ steps.validate_chain.outputs.check }}
steps:
- name: Validate Chain
id: validate_chain
run: |
chain=${{ github.event.inputs.chain }}
tag=$(echo '${{ github.event.inputs.tag-height-proposal }}' | jq '.tag')
height=$(echo '${{ github.event.inputs.tag-height-proposal }}' | jq '.height')
proposal=$(echo '${{ github.event.inputs.tag-height-proposal }}' | jq '.proposal')
cosmos_sdk_version=${{ github.event.inputs.cosmos_sdk_version }}
consensus='${{ github.event.inputs.consensus }}'
cosmwasm_version=${{ github.event.inputs.cosmwasm_version }}
cosmwasm_path=${{ github.event.inputs.cosmwasm_path }}
ibc_go_version=${{ github.event.inputs.ibc_go_version }}
ics_enabled='${{ github.event.inputs.ics_enabled }}'
binaries='${{ github.event.inputs.binaries }}'
echo "$tag $height $proposal"
if [ $chain == '' ]; then
echo "Chain is invalid. Please specify a chain to update."
echo "check=FAILED" >> $GITHUB_OUTPUT
elif [ $tag == '"-1"' ]; then
echo "Tag is invalid."
echo "check=FAILED" >> $GITHUB_OUTPUT
elif [ $proposal != '-1' ] && [ $height == '-1' ]; then
echo "If the chain is consensus break, the height must be specified."
echo "check=FAILED" >> $GITHUB_OUTPUT
else
echo "All inputs look good!"
echo "check=PASSED" >> $GITHUB_OUTPUT
fi
update:
name: Create Version Object and Update
needs: validate_data
runs-on: ubuntu-latest
if: needs.validate_data.outputs.check == 'PASSED'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: 3.11
- name: Export tag
id: export_tag
run: |
tag=$(echo '${{ github.event.inputs.tag-height-proposal }}' | jq '.tag')
tag=${tag//\"}
echo "tag=$tag" >> $GITHUB_OUTPUT
- name: Gen version JSON object
id: version_object
shell: python
run: |
import json
import os
rootdir = os.getcwd()
chain = "${{ github.event.inputs.chain }}"
tag = json.loads('${{ github.event.inputs.tag-height-proposal }}')
height = tag['height']
proposal = tag['proposal']
tag = tag['tag']
cosmos_sdk_version = "${{ github.event.inputs.cosmos_sdk_version }}"
consensus = json.loads('${{ github.event.inputs.consensus }}')
cosmwasm_version = "${{ github.event.inputs.cosmwasm_version }}"
cosmwasm_path = "${{ github.event.inputs.cosmwasm_path }}"
ibc_go_version = "${{ github.event.inputs.ibc_go_version }}"
ics_enabled = json.loads('${{ github.event.inputs.ics_enabled }}')
binaries = json.loads('${{ github.event.inputs.binaries }}')
recommended_version = tag
compatible_versions = [recommended_version]
if cosmwasm_version != '':
cosmwasm_enabled = True
else:
cosmwasm_enabled = False
if proposal != -1: # Consensus-breaking upgrade
name = tag
else: # Non Consensus-breaking upgrade
name = ".".join(tag.split(".")[:2])
newVersion = {
"name": name,
"tag": tag,
"height": height,
"proposal": proposal,
"recommended_version": recommended_version,
"compatible_versions": compatible_versions,
"cosmos_sdk_version": cosmos_sdk_version,
"consensus": consensus,
"cosmwasm_version": cosmwasm_version,
"cosmwasm_path": cosmwasm_path,
"cosmwasm_enabled": cosmwasm_enabled,
"ibc_go_version": ibc_go_version,
"ics_enabled": ics_enabled,
"binaries": binaries
}
chainjson = os.path.join(chain, "chain.json")
current = json.load(open(os.path.join(rootdir, chainjson), encoding='utf-8', errors='ignore'))
current["codebase"]["versions"].append(newVersion)
with open(os.path.join(rootdir, chainjson), "w") as file:
json.dump(current, file, indent=2, ensure_ascii=False)
- name: Add Commit Push
uses: devops-infra/action-commit-push@master
with:
github_token: "${{ secrets.GITHUB_TOKEN }}"
add_timestamp: false
commit_prefix: "[UPGRADE] "
commit_message: "New version update: ${{ github.event.inputs.chain }} ${{ steps.export_tag.outputs.tag }}"
force: false
target_branch: new-version-${{ github.event.inputs.chain }}
- name: Create A PR
uses: devops-infra/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
source_branch: new-version-${{ github.event.inputs.chain }}
target_branch: master
title: "[UPGRADE] ${{ github.event.inputs.chain }} ${{ steps.export_tag.outputs.tag }}"
body: "Chains Updated: ${{ github.event.inputs.chain }}"
old_string: "**THIS IS AN AUTOMATED UPDATE OF CHAIN.JSON**"
new_string: "** Automatic pull request**"
get_diff: true
ignore_users: "dependabot"