Skip to content

Commit

Permalink
Implement use_release_issue
Browse files Browse the repository at this point in the history
Fixes #338
  • Loading branch information
hadley committed Nov 29, 2018
1 parent 00a0bf8 commit 010f947
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 0 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
@@ -1,5 +1,8 @@
# usethis (development version)

* `use_release_issue()` creates a GitHub issue containing a release checklist
capturing best practices discovered by the tidyverse team (#338)

* `use_github_config()` now invisibly returns the previous values of the
settings.

Expand Down
95 changes: 95 additions & 0 deletions R/release.R
@@ -0,0 +1,95 @@
#' Create a release issue checklist
#'
#' When preparing to release a package there are quite a few steps that
#' need to be performed, and some of the steps can take multiple hours.
#' This function creates an issue checklist so that you can keep track of
#' where you are in the process, and feel a sense of satisfaction as you
#' progress. It also helps watchers of your package stay informed about where
#' you are in the process.
#'
#' @param version Version number for release
#' @export
#' \dontrun{
#' use_release_issue("2.0.0")
#' }
use_release_issue <- function(version) {
check_uses_github()
checklist <- release_checklist(version)

issue <- gh::gh("POST /repos/:owner/:repo/issues",
owner = github_owner(),
repo = github_repo(),
title = glue("Release {project_name()} {version}"),
body = paste(checklist, "\n", collapse = "")
)

view_url(issue$html_url)
}

release_checklist <- function(version) {
type <- release_type(version)
on_cran <- !is.null(cran_version())
has_src <- dir_exists(proj_path("src"))

todo <- function(x, cond = TRUE) {
x <- glue(x, .envir = parent.frame())
if (cond) {
paste0("* [ ] ", x)
}
}
c(
"Prepare for release:",
"",
todo("Check that description is informative", !on_cran),
todo("Check licensing of included files", !on_cran),
todo("`usethis::use_cran_comments()`", !on_cran),
todo("`devtools::check()`"),
todo("`devtools::check_win_devel()`"),
todo("`rhub::check_for_cran()`"),
todo("`rhub::check(platform = 'solaris-x86-patched')`", has_src),
todo("`rhub::check(platform = 'ubuntu-rchk')`", has_src),
todo("`rhub::check_with_sanitizers()", has_src),
todo("`revdepcheck::revdep_check(num_workers = 4)`", on_cran),
todo("[Polish NEWS](http://style.tidyverse.org/news.html#before-release)", on_cran),
todo("Draft blog post", type != "patch"),
"",
"Submit to CRAN:",
"",
todo("`usethis::use_version('{version}')`"),
todo("`devtools::check_win_devel()` (again!)"),
todo("`devtools::submit_cran()`"),
todo("Approve email"),
"",
"Wait for CRAN...",
"",
todo("Tag release"),
todo("`usethis::use_dev_version()`"),
todo("`usethis::use_news()`", !on_cran),
todo("Finish blog post", type != "patch"),
todo("Tweet"),
todo("Add link to blog post in pkgdown news menu", type != "patch")
)
}

release_type <- function(version) {
x <- unclass(numeric_version(version))[[1]]
n <- length(x)
if (n >= 3 && x[[3]] != 0L) {
"patch"
} else if (n >= 2 && x[[2]] != 0L) {
"minor"
} else {
"major"
}
}

cran_version <- function(package = project_name(),
available = utils::available.packages()
) {
idx <- available[, "Package"] == package
if (any(idx)) {
as.package_version(available[package, "Version"])
} else {
NULL
}
}
19 changes: 19 additions & 0 deletions man/use_release_issue.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 010f947

Please sign in to comment.