Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ci/cargo publish on release #569

Closed
wants to merge 7 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Publish

on:
push:
tags:
- "**"

jobs:
lint:
if: github.ref == 'refs/heads/main' && github.actor == 'bot-anik'
uses: ./.github/workflows/lint.yml

build:
if: github.ref == 'refs/heads/main' && github.actor == 'bot-anik'
uses: ./.github/workflows/build.yml

test:
if: github.ref == 'refs/heads/main' && github.actor == 'bot-anik'
uses: ./.github/workflows/test.yml

perform-publish:
if: github.ref == 'refs/heads/main' && github.actor == 'bot-anik'
needs:
- lint
- build
- test
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
token: ${{ secrets.OPS_TOKEN }}

- name: Setup rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.75
default: true
override: true

- name: Publish crates to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo make publish-crates
5 changes: 4 additions & 1 deletion .releaserc.yml
Original file line number Diff line number Diff line change
@@ -37,7 +37,10 @@ plugins:
to: version = "${nextRelease.version}"
- - "@semantic-release/exec"
- prepareCmd: |
cargo make schema && cargo make docs-generate && cargo make release-wasm
cargo make update-workspace-dependency-versions ${nextRelease.version} && \
cargo make schema && \
cargo make docs-generate && \
cargo make release-wasm
- - "@semantic-release/github"
- successComment: false
assets:
19 changes: 12 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -2,6 +2,11 @@
members = ["contracts/*", "packages/*"]
resolver = "2"

[workspace.package]
authors = ["AXONE"]
homepage = "https://axone.xyz/"
license-file = "LICENSE"

[profile.release]
codegen-units = 1
debug = false
@@ -16,15 +21,15 @@ rpath = false
[workspace.dependencies]
axone-cognitarium = { path = "contracts/axone-cognitarium", features = [
"library",
] }
axone-cognitarium-client = { path = "packages/axone-cognitarium-client" }
axone-logic-bindings = { path = "packages/axone-logic-bindings" }
], version = "5.0.0" }
Copy link
Member

@amimart amimart Jun 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the need of duplicating the version here, but it brings a new responsibility that is not managed here, this version must be in sync the new released versions. And sadly cargo doesn't come with CLI tools to achieved that 😢..

Currently at release each contracts & packages have their version updated by semantic release, this is configured in the .releaserc.yml. However this replace plugin isn't suitable to update versions in the dependency list..

I think we could easily script this update using toml-cli, for example:

toml set Cargo.toml workspace.dependencies.axone-rdf.version 4.1.0

I think the changes made by toml-cli may need to be properly formatted to please the linter, and committed in the release commit.

All this logic may be embedded in a new task in the Makefile.toml I think.

axone-cognitarium-client = { path = "packages/axone-cognitarium-client", version = "5.0.0" }
axone-logic-bindings = { path = "packages/axone-logic-bindings", version = "5.0.0" }
axone-objectarium = { path = "contracts/axone-objectarium", features = [
"library",
] }
axone-objectarium-client = { path = "packages/axone-objectarium-client" }
axone-rdf = { path = "packages/axone-rdf" }
axone-wasm = { path = "packages/axone-wasm" }
], version = "5.0.0" }
axone-objectarium-client = { path = "packages/axone-objectarium-client", version = "5.0.0" }
axone-rdf = { path = "packages/axone-rdf", version = "5.0.0" }
axone-wasm = { path = "packages/axone-wasm", version = "5.0.0" }
cosmwasm-schema = "1.5.5"
cosmwasm-std = { version = "1.5.5", features = ["cosmwasm_1_2"] }
cosmwasm-storage = "1.5.2"
30 changes: 30 additions & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
@@ -600,6 +600,30 @@ docker run --rm \
| jq -r '.'
'''

[tasks.update-workspace-dependency-versions]
dependencies = ["install-toml-cli"]
script = '''
next_version=$1

workspace_dependencies=( \
axone-cognitarium \
axone-rdf \
axone-wasm \
axone-cognitarium-client \
axone-logic-bindings \
axone-objectarium \
axone-objectarium-client \
)

for workspace_dependency in ${workspace_dependencies[@]}; do
toml set Cargo.toml workspace.dependencies.$workspace_dependency.version $next_version > Cargo.toml.tmp && mv Cargo.toml.tmp Cargo.toml
done
'''
Comment on lines +603 to +621
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review the script for updating workspace dependency versions.

The script updates the versions of specified workspace dependencies in Cargo.toml. Ensure that the command toml set correctly modifies the file and that the temporary file handling is secure and error-proof.

- toml set Cargo.toml workspace.dependencies.$workspace_dependency.version $next_version > Cargo.toml.tmp && mv Cargo.toml.tmp Cargo.toml
+ toml set Cargo.toml workspace.dependencies.$workspace_dependency.version $next_version > Cargo.toml.tmp
+ if [ $? -eq 0 ]; then
+   mv Cargo.toml.tmp Cargo.toml
+ else
+   echo "Error updating workspace dependency versions"
+   rm Cargo.toml.tmp
+   exit 1
+ fi
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
[tasks.update-workspace-dependency-versions]
dependencies = ["install-toml-cli"]
script = '''
next_version=$1
workspace_dependencies=( \
axone-cognitarium \
axone-rdf \
axone-wasm \
axone-cognitarium-client \
axone-logic-bindings \
axone-objectarium \
axone-objectarium-client \
)
for workspace_dependency in ${workspace_dependencies[@]}; do
toml set Cargo.toml workspace.dependencies.$workspace_dependency.version $next_version > Cargo.toml.tmp && mv Cargo.toml.tmp Cargo.toml
done
'''
[tasks.update-workspace-dependency-versions]
dependencies = ["install-toml-cli"]
script = '''
next_version=$1
workspace_dependencies=( \
axone-cognitarium \
axone-rdf \
axone-wasm \
axone-cognitarium-client \
axone-logic-bindings \
axone-objectarium \
axone-objectarium-client \
)
for workspace_dependency in ${workspace_dependencies[@]}; do
toml set Cargo.toml workspace.dependencies.$workspace_dependency.version $next_version > Cargo.toml.tmp
if [ $? -eq 0 ]; then
mv Cargo.toml.tmp Cargo.toml
else
echo "Error updating workspace dependency versions"
rm Cargo.toml.tmp
exit 1
fi
done
'''


[tasks.publish-crates]
dependencies = ["install-cargo-workspaces"]
script = "cargo workspaces publish --publish-as-is"

[tasks.install-llvm-tools-preview]
install_crate = { rustup_component_name = "llvm-tools-preview" }

@@ -637,6 +661,12 @@ fi
[tasks.install-cargo-hack]
install_crate = { crate_name = "cargo-hack", min_version = "0.6.14" }

[tasks.install-toml-cli]
install_crate = { crate_name = "toml-cli", min_version = "0.2.3" }

[tasks.install-cargo-workspaces]
install_crate = { crate_name = "cargo-workspaces", min_version = "0.3.2" }

[config]
default_to_workspace = false
min_version = "0.36.3"
9 changes: 8 additions & 1 deletion contracts/axone-cognitarium/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
[package]
authors = ["AXONE"]
authors.workspace = true
categories = ["cryptography::cryptocurrencies"]
description = "A CosmWasm Smart Contract which enables the storage and querying of Semantic data using RDF (Resource Description Framework), which represents information as semantic triples."
documentation = "https://docs.axone.xyz/contracts/okp4-cognitarium"
edition = "2021"
homepage.workspace = true
license-file.workspace = true
name = "axone-cognitarium"
readme = "README.md"
repository = "https://github.com/axone-protocol/contracts/tree/main/contracts/axone-cognitarium"
rust-version = "1.75"
version = "5.0.0"

9 changes: 8 additions & 1 deletion contracts/axone-dataverse/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
[package]
authors = ["AXONE"]
authors.workspace = true
categories = ["cryptography::cryptocurrencies"]
description = 'A CosmWasm Smart Contract which enables the orchestration of "Dataverses", a collection of digital resources governed by rules set by what is called a "Zone".'
documentation = "https://docs.axone.xyz/contracts/okp4-dataverse"
edition = "2021"
homepage.workspace = true
license-file.workspace = true
name = "axone-dataverse"
readme = "README.md"
repository = "https://github.com/axone-protocol/contracts/tree/main/contracts/axone-dataverse"
rust-version = "1.75"
version = "5.0.0"

9 changes: 8 additions & 1 deletion contracts/axone-law-stone/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
[package]
authors = ["AXONE"]
authors.workspace = true
categories = ["cryptography::cryptocurrencies"]
description = "A CosmWasm Smart Contract which aims to provide GaaS (Governance as a Service) in any Cosmos blockchains."
documentation = "https://docs.axone.xyz/contracts/okp4-law-stone"
edition = "2021"
homepage.workspace = true
license-file.workspace = true
name = "axone-law-stone"
readme = "README.md"
repository = "https://github.com/axone-protocol/contracts/tree/main/contracts/axone-law-stone"
rust-version = "1.75"
version = "5.0.0"

13 changes: 12 additions & 1 deletion contracts/axone-objectarium/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
[package]
authors = ["AXONE"]
authors.workspace = true
categories = [
"cryptography::cryptocurrencies",
"data-structures",
"database-implementations",
]
description = "A CosmWasm Smart Contract which enables the storage of arbitrary unstructured Objects in any Cosmos blockchains."
documentation = "https://docs.axone.xyz/contracts/okp4-objectarium"
edition = "2021"
homepage.workspace = true
license-file.workspace = true
name = "axone-objectarium"
readme = "README.md"
repository = "https://github.com/axone-protocol/contracts/tree/main/contracts/axone-objectarium"
rust-version = "1.75"
version = "5.0.0"

9 changes: 8 additions & 1 deletion packages/axone-cognitarium-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
[package]
authors = ["AXONE"]
authors.workspace = true
categories = ["cryptography::cryptocurrencies"]
description = "Package that holds components to interact with the `axone-cognitarium` contract."
documentation = "https://docs.axone.xyz/contracts/okp4-cognitarium"
edition = "2021"
homepage.workspace = true
license-file.workspace = true
name = "axone-cognitarium-client"
readme = "README.md"
repository = "https://github.com/axone-protocol/contracts/tree/main/packages/axone-cognitarium-client"
version = "5.0.0"

[dependencies]
9 changes: 8 additions & 1 deletion packages/axone-logic-bindings/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
[package]
authors = ["AXONE"]
authors.workspace = true
categories = ["cryptography::cryptocurrencies"]
description = "Package that holds all bindings for querying the AXONE logic module."
documentation = "https://docs.axone.xyz/modules/logic"
edition = "2021"
homepage.workspace = true
license-file.workspace = true
name = "axone-logic-bindings"
readme = "README.md"
repository = "https://github.com/axone-protocol/contracts/tree/main/packages/axone-logic-bindings"
version = "5.0.0"

[dependencies]
9 changes: 8 additions & 1 deletion packages/axone-objectarium-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
[package]
authors = ["AXONE"]
authors.workspace = true
categories = ["cryptography::cryptocurrencies"]
description = "Package that holds components to interact with the `axone-objectarium` contract."
documentation = "https://docs.axone.xyz/contracts/okp4-objectarium"
edition = "2021"
homepage.workspace = true
license-file.workspace = true
name = "axone-objectarium-client"
readme = "README.md"
repository = "https://github.com/axone-protocol/contracts/tree/main/packages/axone-objectarium-client"
version = "5.0.0"

[dependencies]
9 changes: 8 additions & 1 deletion packages/axone-rdf/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
[package]
authors = ["AXONE"]
authors.workspace = true
categories = ["data-structures", "parser-implementations"]
description = "Package that holds useful components to manage with `RDF` data, typically reading / writing."
documentation = "https://docs.axone.xyz/contracts/okp4-cognitarium#model-your-data-with-rdf"
edition = "2021"
homepage.workspace = true
license-file.workspace = true
name = "axone-rdf"
readme = "README.md"
repository = "https://github.com/axone-protocol/contracts/tree/main/packages/axone-rdf"
version = "5.0.0"

[dependencies]
13 changes: 12 additions & 1 deletion packages/axone-wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
[package]
authors = ["AXONE"]
authors.workspace = true
categories = [
"cryptography::cryptocurrencies",
"parser-implementations",
"data-structures",
]
description = "Package that holds useful components to manage with `CosmWasm` data, typically reading / writing."
documentation = "https://docs.axone.xyz/predicates/open_4#cosmwasm-uri"
edition = "2021"
homepage.workspace = true
license-file.workspace = true
name = "axone-wasm"
readme = "README.md"
repository = "https://github.com/axone-protocol/contracts/tree/main/packages/axone-wasm"
version = "5.0.0"

[dependencies]
4 changes: 2 additions & 2 deletions packages/axone-wasm/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# RDF
# WASM

Package that holds useful components to manage with `RDF` data, typically reading / writing.
Package that holds useful components to manage with `CosmWasm` data, typically reading / writing.