Skip to content

Commit

Permalink
Merge pull request #505 from okp4/ci/release-optimized-wasm
Browse files Browse the repository at this point in the history
ci(release): use cw optimizer to build wasm assets
  • Loading branch information
amimart authored Mar 8, 2024
2 parents f403fc2 + 0e607f1 commit 4c81b9d
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 46 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ jobs:
with:
node-version: 20

- name: Setup jq
uses: dcarbone/install-jq-action@v2
with:
version: 1.7
force: true

- name: Setup rust
uses: actions-rs/toolchain@v1
with:
Expand Down
4 changes: 2 additions & 2 deletions .releaserc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ plugins:
to: version = "${nextRelease.version}"
- - "@semantic-release/exec"
- prepareCmd: |
cargo make schema && cargo make docs-generate && cargo make release-assets
cargo make schema && cargo make docs-generate && cargo make release-wasm
- - "@semantic-release/github"
- assets:
- path: "./target/wasm32-unknown-unknown/release/okp4_objectarium.wasm"
- path: "./target/wasm32-unknown-unknown/release/okp4_law_stone.wasm"
- path: "./target/wasm32-unknown-unknown/release/okp4_cognitarium.wasm"
- path: "./target/wasm32-unknown-unknown/release/okp4_dataverse.wasm"
- path: "./target/wasm32-unknown-unknown/release/sha256sum.txt"
- path: "./target/wasm32-unknown-unknown/release/checksums.txt"
- path: "./contracts/okp4-objectarium/schema/okp4-objectarium.json"
- path: "./contracts/okp4-law-stone/schema/okp4-law-stone.json"
- path: "./contracts/okp4-cognitarium/schema/okp4-cognitarium.json"
Expand Down
22 changes: 10 additions & 12 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -208,19 +208,17 @@ npx --yes [email protected] docs/*.md --write
echo "📖 Documentation has been successfully generated and available at $(pwd)/$DOCS_FOLDER/README.md"
'''

[tasks.release-assets]
dependencies = ["wasm"]
[tasks.release-wasm]
description = "Build optimized wasm using CosmWasm optimizer and provide checksums"
script = '''
echo "🐾 Generating release binary checksums into ${DIR_WASM}"
{
cd ${DIR_WASM}
rm sha256sum.txt || true
touch sha256sum.txt
for asset in `ls *.wasm`; do
shasum -a 256 ${asset} >> sha256sum.txt
done
}
echo "📦 Generating release binaries and checksums into ${DIR_WASM}"
docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/optimizer:0.15.1
mv artifacts/* ${DIR_WASM}
rmdir artifacts
'''

[tasks.scaffold-smart-contract]
Expand Down
7 changes: 0 additions & 7 deletions contracts/okp4-cognitarium/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,3 @@ cw-multi-test.workspace = true
backtraces = ["cosmwasm-std/backtraces"]
# use library feature to disable all instantiate/execute/query exports
library = []

[package.metadata.scripts]
optimize = """docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer:0.12.10
"""
7 changes: 0 additions & 7 deletions contracts/okp4-dataverse/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,3 @@ url = "2.5.0"
backtraces = ["cosmwasm-std/backtraces"]
# use library feature to disable all instantiate/execute/query exports
library = []

[package.metadata.scripts]
optimize = """docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer:0.12.10
"""
7 changes: 0 additions & 7 deletions contracts/okp4-law-stone/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,3 @@ url = "2.5.0"
backtraces = ["cosmwasm-std/backtraces"]
# use library feature to disable all instantiate/execute/query exports
library = []

[package.metadata.scripts]
optimize = """docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer:0.12.10
"""
7 changes: 0 additions & 7 deletions contracts/okp4-objectarium/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,3 @@ cw-multi-test.workspace = true
backtraces = ["cosmwasm-std/backtraces"]
# use library feature to disable all instantiate/execute/query exports
library = []

[package.metadata.scripts]
optimize = """docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer:0.12.10
"""
2 changes: 1 addition & 1 deletion docs/okp4-cognitarium.md
Original file line number Diff line number Diff line change
Expand Up @@ -876,4 +876,4 @@ Represents a condition in a [WhereClause].

---

_Rendered by [Fadroma](https://fadroma.tech) ([@fadroma/schema 1.1.0](https://www.npmjs.com/package/@fadroma/schema)) from `okp4-cognitarium.json` (`e2226c4b5e5780b5`)_
_Rendered by [Fadroma](https://fadroma.tech) ([@fadroma/schema 1.1.0](https://www.npmjs.com/package/@fadroma/schema)) from `okp4-cognitarium.json` (`a0e0b72e96074ba9`)_
2 changes: 1 addition & 1 deletion docs/okp4-dataverse.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,5 +223,5 @@ let b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```
---
*Rendered by [Fadroma](https://fadroma.tech) ([@fadroma/schema 1.1.0](https://www.npmjs.com/package/@fadroma/schema)) from `okp4-dataverse.json` (`200eea4bacd8654a`)*
*Rendered by [Fadroma](https://fadroma.tech) ([@fadroma/schema 1.1.0](https://www.npmjs.com/package/@fadroma/schema)) from `okp4-dataverse.json` (`c007ecd2b9eeb04a`)*
````
2 changes: 1 addition & 1 deletion docs/okp4-law-stone.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,4 @@ A string containing Base64-encoded data.

---

_Rendered by [Fadroma](https://fadroma.tech) ([@fadroma/schema 1.1.0](https://www.npmjs.com/package/@fadroma/schema)) from `okp4-law-stone.json` (`b66539ab7e1aaf9c`)_
_Rendered by [Fadroma](https://fadroma.tech) ([@fadroma/schema 1.1.0](https://www.npmjs.com/package/@fadroma/schema)) from `okp4-law-stone.json` (`d7f05e6c973e01e6`)_
2 changes: 1 addition & 1 deletion docs/okp4-objectarium.md
Original file line number Diff line number Diff line change
Expand Up @@ -511,4 +511,4 @@ A string containing a 128-bit integer in decimal representation.

---

_Rendered by [Fadroma](https://fadroma.tech) ([@fadroma/schema 1.1.0](https://www.npmjs.com/package/@fadroma/schema)) from `okp4-objectarium.json` (`6e145d8e13059aaa`)_
_Rendered by [Fadroma](https://fadroma.tech) ([@fadroma/schema 1.1.0](https://www.npmjs.com/package/@fadroma/schema)) from `okp4-objectarium.json` (`26379e2de2530668`)_

0 comments on commit 4c81b9d

Please sign in to comment.