From 9a827afff2259a938732fd59f452a1a5e2abf178 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Wed, 4 Dec 2024 14:16:58 +0100 Subject: [PATCH] fix: `release_after_cran_built_binaries()` works correctly again (#848) --- R/auto.R | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/R/auto.R b/R/auto.R index 8601331b..c9aa6b96 100644 --- a/R/auto.R +++ b/R/auto.R @@ -551,12 +551,15 @@ post_release_impl <- function() { # End extension points } -create_github_release <- function() { - # FIXME: Extract function, add test - version <- get_last_release_version() +create_github_release <- function(version) { + fledgling <- read_fledgling() + + version <- get_last_release_version(fledgling) tag <- paste0("v", version) - if (fledge_chatty()) cli_alert("Creating GitHub release {.val {tag}}.") + if (fledge_chatty()) { + cli_alert("Creating GitHub release {.val {tag}}.") + } if (nzchar(Sys.getenv("FLEDGE_TEST_NOGH"))) { cli_alert("Omitting in test.") @@ -576,8 +579,6 @@ create_github_release <- function() { return(invisible()) } - fledgling <- read_fledgling() - stopifnot(sum(fledgling[["news"]]$version == version) == 1) header <- paste0(fledgling$name, " ", version) body <- fledgling[["news"]]$raw[fledgling[["news"]]$version == version] @@ -806,11 +807,18 @@ release_after_cran_built_binaries <- function() { } } -get_last_release_version <- function() { - tag_df <- get_last_version_tag_impl( - pattern = "^v[0-9]+[.][0-9]+[.][0-9]+(?:[.-][0-9]{1,3})?$" - ) - as.package_version(gsub("^v", "", tag_df$name)) +get_last_release_version <- function(fledgling = NULL) { + if (is.null(fledgling)) { + fledgling <- read_fledgling() + } + + is_release <- grep("^[0-9]+[.][0-9]+[.][0-9]+(?:[.-][0-9]{1,3})?$", fledgling$version) + + if (length(is_release) == 0) { + return(NULL) + } + + fledgling$version[[is_release[[1]]]] } cran_release_pr_title <- function(version) {