How to keep codemeta.json up-to-date? In particular, how to keep it up to date with DESCRIPTION
? codemetar
itself no longer supports automatic sync, but there are quite a few methods available out there. Choose one that fits well into your workflow!
You could rely on devtools::release()
since it will ask you whether you updated codemeta.json when such a file exists.
You could use a git pre-commit hook that prevents a commit from being done if DESCRIPTION is newer than codemeta.json.
You can use the precommit package in which there's a "codemeta-description-updated" hook.
If that's your only pre-commit hook (i.e. you don't have one created by e.g. usethis::use_readme_rmd()
), then you can create it using
script = readLines(system.file("templates", "description-codemetajson-pre-commit.sh", package = "codemetar")) usethis::use_git_hook("pre-commit", script = script)
system.file("templates", "codemeta-github-actions.yml", package = "codemetar")
). You can use the cm-skip
keyword in your commit message if you don't want this to run on a specific commit.
The example workflow provided is setup to only run when a push is made to the master branch. This setup is designed for if you're using a git flow setup where the master branch is only committed and pushed to via pull requests. After each PR merge (and the completion of this GitHub action), your master branch will always be up to date and so long as you don't make manual changes to the codemeta.json file, you won't have merge conflicts.Alternatively, you can have GitHub actions route run codemetar
on each commit. If you do this you should try to remember to run git pull
before making any new changes on your local project. However, if you forgot to pull and already committed new changes, fret not, you can use (git pull --rebase
) to rewind you local changes on top of the current upstream HEAD
.
details::details(system.file("templates", "codemeta-github-actions.yml", package = "codemetar"), summary = "click here to see the workflow", lang = "yaml")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.