citation-file-format / cffconvert

Command line program to validate and convert CITATION.cff files.
Apache License 2.0
95 stars 28 forks source link

Keep `communities` and `grants` when exporting to an existing .zenodo.json file #377

Open bouweandela opened 9 months ago

bouweandela commented 9 months ago

In our project, we use the command cffconvert --infile CITATION.cff --format zenodo --outfile .zenodo.json to export contributors from our citation file to our zenodo file. However, this deletes the "communities" and "grants" entries from our .zenodo.json file (see here for a description) and it has already happened several times that new contributors accidentally deleted those in a pull request because not all reviewers understand how citation files and zenodo interact. Would it be possible to change cffconvert so it keeps those entries when writing to an existing file?

sdruskat commented 8 months ago

Thanks @bouweandela for reporting this. I'll transfer the issue to the relevant cffconvert repository.

jspaaks commented 7 months ago

Hi Bouwe,

The way I handle that in my projects is to

  1. have the properties you don't want to overwrite in a file, e.g. .zenodo.extras.json
  2. have cffconvert use the metadata from CITATION.cff to generate the equivalent Zenodo JSON in CI, output in e.g. .zenodo.citation.json
  3. Also in CI, combine them into .zenodo.json with jq before publishing to Zenodo

As follows:

cffconvert --infile CITATION.cff --format zenodo --outfile .zenodo.citation.json
cat .zenodo.citation.json .zenodo.extras.json | jq -s add > .zenodo.json
bouweandela commented 7 months ago

Thanks for the hint! Do I understand it correctly if I think that that will only work if we set up an extra GitHub action to do the publication to Zenodo? Currently, we use the workflow described here.

alexlancaster commented 6 months ago

Thanks for the hint! Do I understand it correctly if I think that that will only work if we set up an extra GitHub action to do the publication to Zenodo? Currently, we use the workflow described here.

yes, I think the automatic Github<->Zenodo integration isn't that smart, it just takes the current repo contents and reads the .zenodo.json, I don't think it even looks at CITATION.cff, according to: https://developers.zenodo.org/#github

you could something like the following:

  1. maintain the Zenodo-specific stuff in .zenodo.extras.json as suggested
  2. then set up an GitHut Action that always generates the new .zenodo.json along the lines that @jspaaks suggests upon a change to CITATION.cff.
  3. that way .zenodo.json would always be up-to-date
  4. the do the GitHub release as usual using the integration - it would then use the generated .zenodo.json

The main issues with this is that you have make sure people don't accidentally modify the .zenodo.json directly, and you also can't have the action commit the changes to your branch if it's protected.