Skip to content

Commit 65f26c4

Browse files
authored
CI Release action to build & deploy CosmWasm contracts (#222)
1 parent efe5f82 commit 65f26c4

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

.github/workflows/release.yml

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,11 @@ jobs:
99
release:
1010
runs-on: ubuntu-latest
1111
permissions:
12-
packages: write
12+
contents: write
1313
steps:
1414
- name: Checkout sources
1515
uses: actions/checkout@v4
1616

17-
- name: Install jq
18-
run: sudo apt-get install jq
19-
2017
- name: Install cargo-run-script
2118
uses: actions-rs/cargo@v1
2219
with:
@@ -54,20 +51,31 @@ jobs:
5451
- name: Install Neutron & import key
5552
run: |
5653
wget -O neutrond https://github.com/neutron-org/neutron/releases/download/v3.0.2/neutrond-linux-amd64
57-
chmod +x neutrond
58-
echo ${{ secrets.TW_CI_NEUTRON_KEY_PASS }} | neutrond keys import tw_ci_neutron tw_ci_neutron.key
54+
chmod +x ./neutrond
55+
./neutrond config chain-id neutron-1
56+
./neutrond config node ${{ vars.NEUTRON_RPC_NODE }}
57+
./neutrond config keyring-backend file
58+
(echo ${{ secrets.TW_CI_NEUTRON_KEY_PASS }}; echo ${{ secrets.TW_CI_NEUTRON_KEY_PASS }}; echo ${{ secrets.TW_CI_NEUTRON_KEY_PASS }}) | ./neutrond keys import tw_ci_neutron tw_ci_neutron.key
5959
6060
- name: Deploy WASM contracts to Neutron
6161
run: |
62-
find ./artifacts -name \*.wasm -exec neutrond tx wasm store {} --from tw_ci_neutron --gas auto --gas-prices 0.01untrn --gas-adjustment 1.3 --output json -y \; -exec sleep 5 \;
62+
echo '' > code_ids.tmp
63+
for f in ./artifacts/*.wasm
64+
do
65+
echo "Processing $f"
66+
tx_output=$(echo ${{ secrets.TW_CI_NEUTRON_KEY_PASS }} | ./neutrond tx wasm store $f --from ${{ vars.TW_CI_NEUTRON_KEY_ADDR }} --gas auto --gas-prices 0.01untrn --gas-adjustment 1.3 --output json -y)
67+
echo $tx_output
68+
sleep 10
69+
tx_hash=$(jq -r '.txhash' <<< "$tx_output")
70+
echo "> TX hash: $tx_hash"
71+
./neutrond query tx $tx_hash -o json | jq '.events[] | select(.type == "store_code") | .attributes | {(.[0].key): .[0].value, (.[1].key): .[1].value}' >> code_ids.tmp
72+
done
73+
jq -s '.' code_ids.tmp > code_ids.json
74+
rm code_ids.tmp
6375
64-
- name: Get contract code IDs
65-
run: |
66-
./neutrond query wasm list-code --reverse --output json | jq -c '.code_infos[] | select(.creator == "${{ tw_ci_neutron }}") | {code_id: .code_id, code_hash: .data_hash|ascii_downcase}' | jq -s . > code_ids.json
67-
6876
- name: Join code IDs & checksums
6977
run: |
70-
jq '[JOIN(INDEX(input[]; .code_hash); .[]; .code_hash; add)]' checksums.json code_ids.json | jq '.[] | [.contract, .code_id] | @tsv' contract_code_ids.txt
78+
jq '[JOIN(INDEX(input[]; .code_checksum); .[]; .code_hash; add)]' checksums.json code_ids.json | jq -r '.[] | [.contract, .code_id] | @tsv' | column -ts $'\t' > contract_code_ids.txt
7179
7280
- name: Append code IDs to release notes
7381
uses: softprops/action-gh-release@v2

Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ repository = "https://github.com/timewave-computer/covenants/stride-covenant"
1212

1313
rust-version = "1.66"
1414

15+
[workspace.metadata.scripts]
16+
optimize = """docker run --rm -v "$(pwd)":/code \
17+
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/target \
18+
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
19+
cosmwasm/optimizer:0.15.1
20+
"""
21+
1522
[profile.release]
1623
codegen-units = 1
1724
debug = false

0 commit comments

Comments
 (0)