@@ -128,10 +128,9 @@ release_checklist <- function(version, on_cran) {
128128 " Wait for CRAN..." ,
129129 " " ,
130130 todo(" Accepted :tada:" ),
131- todo(" `git push`" ),
132131 todo(" `usethis::use_github_release()`" ),
133- todo(" `usethis::use_dev_version()`" ),
134- todo(" `git push` " ),
132+ todo(" `usethis::use_dev_version(push = TRUE )`" ),
133+ todo(" `usethis::use_news_md()` " , ! has_news ),
135134 todo(" Finish blog post" , type != " patch" ),
136135 todo(" Tweet" , type != " patch" ),
137136 todo(" Add link to blog post in pkgdown news menu" , type != " patch" )
@@ -207,28 +206,27 @@ release_type <- function(version) {
207206 }
208207}
209208
210- # ' Draft a GitHub release
209+ # ' Publish a GitHub release
211210# '
212211# ' @description
213- # ' Creates a __draft__ GitHub release for the current package. Once you are
214- # ' satisfied that it is correct, you will need to publish the release from
215- # ' GitHub. The key pieces of info are which commit / SHA to tag, the associated
216- # ' package version, and the relevant NEWS entries.
217- # '
218- # ' If you use `devtools::release()` or `devtools::submit_cran()` to submit to
219- # ' CRAN, information about the submitted state is captured in a CRAN-SUBMISSION
220- # ' or CRAN-RELEASE file. `use_github_release()` uses this info to populate the
221- # ' draft GitHub release and, after success, deletes the CRAN-SUBMISSION or
222- # ' CRAN-RELEASE file.
212+ # ' Pushes the current branch (if safe) then publishes a GitHub release for the
213+ # ' latest CRAN submission.
223214# '
224- # ' In the absence of such a file, we must fall back to assuming the current
225- # ' state (SHA of `HEAD`, package version, NEWS) is the submitted state.
215+ # ' If you use [devtools::submit_cran()] to submit to CRAN, information about the
216+ # ' submitted state is captured in a `CRAN-SUBMISSION` file.
217+ # ' `use_github_release()` uses this info to populate the GitHub release notes
218+ # ' and, after success, deletes the file. In the absence of such a file, we
219+ # ' assume that current state (SHA of `HEAD`, package version, NEWS) is the
220+ # ' submitted state.
226221# '
227222# ' @param host,auth_token `r lifecycle::badge("deprecated")`: No longer
228223# ' consulted now that usethis allows the gh package to lookup a token based on
229224# ' a URL determined from the current project's GitHub remotes.
225+ # ' @param publish If `TRUE`, publishes a release. If `FALSE`, creates a draft
226+ # ' release.
230227# ' @export
231- use_github_release <- function (host = deprecated(),
228+ use_github_release <- function (publish = TRUE ,
229+ host = deprecated(),
232230 auth_token = deprecated()) {
233231 check_is_package(" use_github_release()" )
234232 if (lifecycle :: is_present(host )) {
@@ -239,7 +237,7 @@ use_github_release <- function(host = deprecated(),
239237 }
240238
241239 tr <- target_repo(github_get = TRUE , ok_configs = c(" ours" , " fork" ))
242- check_can_push(tr = tr , " to draft a release" )
240+ check_can_push(tr = tr , " to create a release" )
243241
244242 dat <- get_release_data(tr )
245243 release_name <- glue(" {dat$Package} {dat$Version}" )
@@ -248,26 +246,33 @@ use_github_release <- function(host = deprecated(),
248246 kv_line(" Tag name" , tag_name )
249247 kv_line(" SHA" , dat $ SHA )
250248
249+ if (git_can_push()) {
250+ git_push()
251+ }
251252 check_github_has_SHA(SHA = dat $ SHA , tr = tr )
252253
253254 on_cran <- ! is.null(cran_version())
254255 news <- get_release_news(SHA = dat $ SHA , tr = tr , on_cran = on_cran )
255256
256257 gh <- gh_tr(tr )
258+
259+ ui_cli_inform(" Publishing {tag_name} release to GitHub" )
257260 release <- gh(
258261 " POST /repos/{owner}/{repo}/releases" ,
259- name = release_name , tag_name = tag_name ,
260- target_commitish = dat $ SHA , body = news , draft = TRUE
262+ name = release_name ,
263+ tag_name = tag_name ,
264+ target_commitish = dat $ SHA ,
265+ body = news ,
266+ draft = ! publish
261267 )
268+ ui_cli_inform(" Release at {.url {release$html_url}}" )
262269
263270 if (! is.null(dat $ file )) {
264- ui_done( " {ui_path( dat$file)} deleted " )
271+ ui_cli_inform( " Deleting {.path { dat$file}} " )
265272 file_delete(dat $ file )
266273 }
267274
268- Sys.sleep(1 )
269- view_url(release $ html_url )
270- ui_todo(" Publish the release via \" Edit draft\" > \" Publish release\" " )
275+ invisible ()
271276}
272277
273278get_release_data <- function (tr = target_repo(github_get = TRUE )) {
0 commit comments