DigitalArsenal / spacedatastandards.org

Data Standards For Space Data Systems
19 stars 7 forks source link

add support for publishing to crates.io #23

Closed shanebenlolo closed 2 months ago

shanebenlolo commented 4 months ago

This MR adds support for publishing the rust code generated by Google's FlatBuffers compiler to crates.io. Hopefully I did this right, please review carefully. I did a test run on my local crates.io account here: https://crates.io/crates/publish_cargo_test all credits in the cargo.toml point back to this repo, I just didn't want to push to digitalarsenal-standards without permission

I was able to create a new project, install the lib, and succesfully run the following program:

use publish_cargo_test::BOV::main_generated::*;

fn main() {
    println!("Hello, world!");
    let mut test = BOVT::default();
    println!("{:?}", test);
}

The README contains instructions on how to publish the crate, please let me know if you have any questions.

My only concern was that I manually moved the generated files from /lib/rs/ --> /lib/rs/src, please let me know if you think this will be an issue. We can generate the lib.rs and main_generated.rs and move the generated code into the src folder programmatically as part of the publishing script if needed, but I am hoping we can instead just point the output of the rust code into the lib/rs/src directory as a simpler solution.

shanebenlolo commented 4 months ago

I've depreciated the version of my test package containing spacedatastandards code: https://crates.io/crates/publish_cargo_test/versions I am happy to reverse that if you'd like to try it yourself but I didn't feel comfortable letting others download it without your approval.

This will prevent anyone from adding it to their project. It has 0 downloads and will now stay that way 👍

shanebenlolo commented 4 months ago

I've pushed some changes to more closely align with the contributors guide, thanks for providing that.

I think I am still off on a couple of components. My script currently does the following:

I still have a publish shell script and an env example file in the rs package. Please let me know what the ideal workflow is. Is the ideal scenario that I can run the node script, pass it in the required credentials, and it will publish the package then reset the file structure?

I will make changes accordingly based on your feedback and then this should be ready!

TJKoury commented 4 months ago

Thanks for the updates!

The ideal workflow is running 'npm run deploy' will deploy to all package managers with the new version. Currently it only deploys to (NPM)[https://www.npmjs.com/package/spacedatastandards.org] using the npm publish command. You should write a shell script (or a node script), and call it in another npm script publish:rs similar to the publish:js, then add && npm run publish:rs to the end of the deploy task.

The credentials should be loaded from a file that is added to the .gitignore file, if they cannot be stored / loaded from a standard location outside the repository (which is what npm does with global account settings). Do what you think is best, making sure the credentials do not get pushed to the repo.