Workflow to release an R package to CRAN

A guide for users of both the GitHub worflow and Gitflow workflow.

Mauro Lepore https://github.com/maurolepore
2021-10-22

Table of Contents


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).

Prepare for release

Consider the release of maurolepore/releaseworkflow v0.0.12.

Did anything change?

Create GitHub release

Regardless of CRAN create a GitHub release:

Continue development

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.


  1. 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.

  2. See Mauro’s aliases under the section “CRAN release”.

  3. 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).

  4. This branch is special only in the gitflow workflow; in the github workflow it’s just like any branch other than master.

  5. This branch is special only in the gitflow workflow; in the github workflow it’s just like any branch other than master.

  6. 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).

  7. 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.

  8. The git flow merges release features automatically into both master and devleop (see https://bit.ly/gitflow-table).

Citation

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}
}