How to automate custom build tasks, eg, releases?



I’d like to automate my release processes, but I am not sure about the best practice here. I understand that Cargo offers no “custom tasks”, so how do you implement custom build tasks in your Rust projects?

I know that I could just write shell (Python, Ruby, etc.) scripts and put these in my source code, but I’d rather prefer if I did not need to setup two (or even more) language environments to work on my projects—in particular on Windows.

So what’s your recommendation or best practice here?


PS: I’m aware of cargo-release but it doesn’t suite my needs. It seems to be geared towards manual releases, whereas I’d like my CI to take care of publishing, etc. and only do essential things locally, in particular bumping the version and updating the changelog.


You can do something like cargo new --bin tasks, and, write automation as usual Rust program, and then run it as cargo run --manifest-path ./tasks/Cargo.toml --bin task-foo. That way, you get a cross-platform “scripting” environment, which could use serde and other goodies from, provided that you have Cargo on the target machine.

If you add more hacks, you can even make it feel built-in: :slight_smile: We also plan to add something similar as a first-class feature to Cargo:


Thank you very much; that’s a really nice idea. Also thanks for linking these two posts; learned a lot about Cargo in both!


There is also cargo make which may also fit your use case.