-
Notifications
You must be signed in to change notification settings - Fork 34
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
Bash-friendly way to query cargo metadata (package version) #33
Comments
Is your need as much about querying the version or just streamlining creating tarballs of your application? I'm working on crate-ci/meta#1 which should help with tarballing. My goal is to have a prototype of |
Not too advanced at using
I use it in a Makefile as: PKG_VERSION = $(shell awk -F ' = ' '$$1 ~ /version/ { gsub(/[\"]/, "", $$2); printf("%s",$$2) }' Cargo.toml) |
i had to use a double backslash and remove the space around the equal sign as below to get it to not error
otherwise i'd get error but i was using this Cargo.toml file, where there's also a a
but when i only want the and some Cargo.toml files choose to use the following format to list their
and the order that |
i wrote this script https://github.com/ltfschoen/kobold-test/blob/master/set_cargo_package_version.sh that finds the line number of cargo build --release
# run this script to set the environment variable CARGO_PACKAGE_VERSION of the calling shell with the value of the [package] version (assuming its not a workspace Cargo.toml file that does not have it.
. ./set_cargo_package_version.sh
tar cjf app-$CARGO_PACKAGE_VERSION.tar.gz target/release/app
rsync etc. if you've got a simple Cargo.toml file that doesn't have other
|
Related to #8
I package my apps with a bash script sort of like this:
cargo build --release tar cjf app-$VERSION.tar.gz target/release/app rsync etc.
The problematic part is
$VERSION
. I would like to read the version fromCargo.toml
, but can't without string manipulation in bash (yuck!)I'd be great if there was something like
cargo metadata --query package.version
that outputs nothing by the given Cargo.toml key.The text was updated successfully, but these errors were encountered: