A guide for users of both the GitHub worflow and Gitflow workflow.
The goal of this post is to help you release an R package to CRAN. It works whether you use the GitHub workflow (video) or the Gitflow workflow1 (video).
Consider the release of maurolepore/releaseworkflow v0.0.12.
usethis::use_release_issue()3.prepare-v0.0.1) and follow the release checklist until the end of the section “Prepare for release” (tweaks).Yes – the package is not ready for release yet:
No – the package is ready for release:
Delete the feature/branch prepare-v0.0.1 and create a release/branch v0.0.15.
Increment the version number with usethis::use_version().
Submit a pull request based on master and confirm clean CI.
devtools::submit_cran(). This adds CRAN-RELEASE – delete it.
Regardless of CRAN create a GitHub release:
master, checkout master, and run usethis::use_github_release()6 to create a new tag v0.0.17 and a corresponding GitHub release.develop8 and checkout develop now.usethis::use_dev_version().You can continue development. If CRAN accepts the submission, then the new tag on master and GitHub release will also have a corresponding CRAN release.
If you use the Gitflow workflow, this article assumes you a) use the git flow extension and b) have privileges to push to origin/master and origin/develop.↩
Ensure your remote origin points to the source repo (i.e. your remote setup is “Ours”). This will fail if your remote origin points elsewhere (e.g. your fork).↩
This branch is special only in the gitflow workflow; in the github workflow it’s just like any branch other than master.↩
This branch is special only in the gitflow workflow; in the github workflow it’s just like any branch other than master.↩
Ensure your remote origin points to the source repo (i.e. your remote setup is “Ours”). This will fail if your remote origin points elsewhere (e.g. your fork).↩
The git flow extension prompts you to enter the tag manually. Use the form vx.y.z like usethis::use_github_release() does. This avoids tagging the same commit twice.↩
The git flow merges release features automatically into both master and devleop (see https://bit.ly/gitflow-table).↩
For attribution, please cite this work as
Lepore (2021, Oct. 22). Data science at 2DII: Workflow to release an R package to CRAN. Retrieved from https://2degreesinvesting.github.io/posts/2021-10-22-workflow-to-release-an-r-package-to-cran/
BibTeX citation
@misc{lepore2021workflow,
author = {Lepore, Mauro},
title = {Data science at 2DII: Workflow to release an R package to CRAN},
url = {https://2degreesinvesting.github.io/posts/2021-10-22-workflow-to-release-an-r-package-to-cran/},
year = {2021}
}