Bash script extract toml version

I have “build” (copied code from II) some GitHub actions to build my Rust canisters in GitHub actions. The jobs run on releases and I attach the generated wasm to the artifacts of the release. Since the repo contains multiple canisters, it is possible that I create release without any changes to some.

That’s is why - better idea welcomed btw. - that I would like to automatically suffix the artifacts with their effective version number as provided in the toml file.

Being really lame at bash, I was asking my self if anyone as an existing script or command line to share that would extract such information?

You could do something like pipe the output of cargo metadata to jq.

Or, write a basic Rust program that prints the version where const VERSION: &str = env!("CARGO_PKG_VERSION");

1 Like

Thanks, cargo metadata was the key.

Something like following should do:

cargo metadata --format-version 1  | jq -r '.packages[]  | select(.name | test("console")) | .version'

where console is the name of my canister.

1 Like