From 08be09c106f78ad20ef1b7c5c082a694530d978d Mon Sep 17 00:00:00 2001 From: Charlotte Wickham Date: Wed, 16 Oct 2024 14:54:08 -0700 Subject: [PATCH 1/6] Script to automate release notes --- tools/release-notes.R | 65 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 tools/release-notes.R diff --git a/tools/release-notes.R b/tools/release-notes.R new file mode 100644 index 0000000000..23339ec19a --- /dev/null +++ b/tools/release-notes.R @@ -0,0 +1,65 @@ +library(fs) +library(stringr) +library(glue) + +# Version numbers +old_release <- "v1.5.57" +new_release_major <- "1.6" +new_prerelease_major <- "1.7" + +major_version <- str_extract(old_release, "(\\d+)\\.(\\d+)") + +downloads <- path("docs", "download") + +# Create new changelog content ------------------------------------------- + +changelog_url <- paste0("https://github.com/quarto-dev/quarto-cli/releases/download/", + old_release, "/changelog.md") +changelog_dir <- dir_create(path(downloads, "changelog", major_version)) + +download_status <- download.file(changelog_url, path(changelog_dir, + "_changelog", ext = "md")) +stopifnot(!download_status) + +glue(" +--- +title: {major_version} Release Notes +format: html +--- + +{{{{< include _changelog.md >}}}} +") |> + writeLines(path(changelog_dir, "index", ext = "qmd")) + +# Increment versions of aliases ------------------------------------------ + +release_page <- path(downloads, "release", ext = "qmd") +prerelease_page <- path(downloads, "prerelease", ext = "qmd") + +aliases <- paste0("changelog/", + c(major_version, new_release_major, new_prerelease_major), + "/") + +readLines(release_page) |> + str_replace(aliases[1], aliases[2]) |> + writeLines(release_page) + +readLines(prerelease_page) |> + str_replace(aliases[2], aliases[3]) |> + writeLines(prerelease_page) + +# MANUALLY update listing ------------------------------------------------ + +old_abbr <- str_split(major_version, "\\.")[[1]] |> paste0(collapse = "") + +# Add new item to download-older listing in docs/download/index.qmd + +cat("Please manually add a new item to the `download-older` listing in `docs/download/index.qmd`:\n") +glue(' +- id: version{ old_abbr } + title: { old_release } + date: + path: https://github.com/quarto-dev/quarto-cli/releases/tag/{ old_release } + changelog: "[Release Notes](changelog/{ major_version }/)" +') + From 2649e35eaa3d977d4659044b39c094ada1f734a0 Mon Sep 17 00:00:00 2001 From: Charlotte Wickham Date: Mon, 21 Oct 2024 13:32:35 -0700 Subject: [PATCH 2/6] Use YAML file for listing --- docs/download/_download-older.yml | 22 +++++++++++++++++++++- docs/download/index.qmd | 26 +------------------------- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/docs/download/_download-older.yml b/docs/download/_download-older.yml index 2d8a3ea3f7..9d77f17e11 100644 --- a/docs/download/_download-older.yml +++ b/docs/download/_download-older.yml @@ -1,6 +1,26 @@ # Generate tags for a specific prefix like so # git tag -l 'v1\.0\.*' --sort version:refname +- id: version14 + title: v1.4.557 + date: 2024/06/27 + path: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.4.557 + changelog: "[Release Notes](changelog/1.4/)" +- id: version13 + title: v1.3.450 + date: 2023/08/23 + path: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.3.450 + changelog: "[Release Notes](changelog/1.3/)" +- id: version12 + title: v1.2.475 + date: 2023/03/22 + path: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.2.475 + changelog: "[Release Notes](changelog/1.2/)" +- id: version11 + title: v1.1.189 + date: 2022/09/04 + path: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.1.189 + changelog: "[Release Notes](changelog/1.1/)" - id: version10 title: v1.0.38 date: 2022/08/04 - url: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.0.38 \ No newline at end of file + path: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.0.38 diff --git a/docs/download/index.qmd b/docs/download/index.qmd index 72abc68389..95ad7e4b6d 100644 --- a/docs/download/index.qmd +++ b/docs/download/index.qmd @@ -20,31 +20,7 @@ editor: source image: /images/hero_right.png listing: id: download-older - contents: - - id: version14 - title: v1.4.557 - date: 2024/06/27 - path: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.4.557 - changelog: "[Release Notes](changelog/1.4/)" - - id: version13 - title: v1.3.450 - date: 2023/08/23 - path: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.3.450 - changelog: "[Release Notes](changelog/1.3/)" - - id: version12 - title: v1.2.475 - date: 2023/03/22 - path: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.2.475 - changelog: "[Release Notes](changelog/1.2/)" - - id: version11 - title: v1.1.189 - date: 2022/09/04 - path: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.1.189 - changelog: "[Release Notes](changelog/1.1/)" - - id: version10 - title: v1.0.38 - date: 2022/08/04 - path: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.0.38 + contents: /_download-older.yml fields: - title - changelog From eab5443e498f15208e307e998f215a494a6a604a Mon Sep 17 00:00:00 2001 From: Charlotte Wickham Date: Mon, 21 Oct 2024 13:38:59 -0700 Subject: [PATCH 3/6] Reverse order for consistency --- docs/download/_download-older.yml | 39 ++++++++++++++++--------------- docs/download/index.qmd | 1 + 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/docs/download/_download-older.yml b/docs/download/_download-older.yml index 9d77f17e11..4aead40a4b 100644 --- a/docs/download/_download-older.yml +++ b/docs/download/_download-older.yml @@ -1,26 +1,27 @@ # Generate tags for a specific prefix like so # git tag -l 'v1\.0\.*' --sort version:refname -- id: version14 - title: v1.4.557 - date: 2024/06/27 - path: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.4.557 - changelog: "[Release Notes](changelog/1.4/)" -- id: version13 - title: v1.3.450 - date: 2023/08/23 - path: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.3.450 - changelog: "[Release Notes](changelog/1.3/)" -- id: version12 - title: v1.2.475 - date: 2023/03/22 - path: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.2.475 - changelog: "[Release Notes](changelog/1.2/)" +- id: version10 + title: v1.0.38 + date: 2022/08/04 + path: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.0.38 - id: version11 title: v1.1.189 date: 2022/09/04 path: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.1.189 changelog: "[Release Notes](changelog/1.1/)" -- id: version10 - title: v1.0.38 - date: 2022/08/04 - path: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.0.38 +- id: version12 + title: v1.2.475 + date: 2023/03/22 + path: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.2.475 + changelog: "[Release Notes](changelog/1.2/)" +- id: version13 + title: v1.3.450 + date: 2023/08/23 + path: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.3.450 + changelog: "[Release Notes](changelog/1.3/)" +- id: version14 + title: v1.4.557 + date: 2024/06/27 + path: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.4.557 + changelog: "[Release Notes](changelog/1.4/)" + \ No newline at end of file diff --git a/docs/download/index.qmd b/docs/download/index.qmd index 95ad7e4b6d..ba6ea91b77 100644 --- a/docs/download/index.qmd +++ b/docs/download/index.qmd @@ -21,6 +21,7 @@ image: /images/hero_right.png listing: id: download-older contents: /_download-older.yml + sort: "date desc" fields: - title - changelog From 5f5c21bbf0e0edef77d138601f26cbedfaac00b6 Mon Sep 17 00:00:00 2001 From: Charlotte Wickham Date: Mon, 21 Oct 2024 13:41:23 -0700 Subject: [PATCH 4/6] Extract version numbers --- tools/release-notes.R | 45 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/tools/release-notes.R b/tools/release-notes.R index 23339ec19a..fb72e3da41 100644 --- a/tools/release-notes.R +++ b/tools/release-notes.R @@ -1,19 +1,52 @@ library(fs) library(stringr) library(glue) +library(jsonlite) +library(gh) + +downloads <- path("docs", "download") + +# Current versions ------------------------------------------------------- + +# Based on updated download files +new_release <- read_json(path(downloads, "_download.json"))$version +new_prerelease <- read_json(path(downloads, "_prerelease.json"))$version + +# Old version from Git history ------------------------------------------- + +# Need version at two commits ago +previous_commit <- gh("https://api.github.com/repos/:owner/:repo/commits", + owner = "quarto-dev", repo = "quarto-web", + path = "docs/download/_download.json", + per_page = 2) + +previous_commit_ref <- previous_commit[[2]]$sha + +previous_contents <- gh("/repos/{owner}/{repo}/contents/{path}", + owner = "quarto-dev", repo = "quarto-web", + path = "docs/download/_download.json", + ref = previous_commit_ref, + .accept = "application/vnd.github.raw+json") +previous_contents_json <- parse_json(previous_contents$message) + +old_release <- previous_contents_json$version +old_release_date <- previous_contents_json$created # Version numbers -old_release <- "v1.5.57" -new_release_major <- "1.6" -new_prerelease_major <- "1.7" +extract_major <- function(x){ + str_extract(x, "(\\d+)\\.(\\d+)") +} -major_version <- str_extract(old_release, "(\\d+)\\.(\\d+)") +new_release_major <- extract_major(new_release) +new_prerelease_major <- extract_major(new_prerelease) +major_version <- extract_major(old_release) -downloads <- path("docs", "download") +cat("Release:", old_release, "->", new_release, "\n") +cat("Prerelease:", major_version, "->", new_prerelease_major, "\n") # Create new changelog content ------------------------------------------- -changelog_url <- paste0("https://github.com/quarto-dev/quarto-cli/releases/download/", +changelog_url <- paste0("https://github.com/quarto-dev/quarto-cli/releases/download/v", old_release, "/changelog.md") changelog_dir <- dir_create(path(downloads, "changelog", major_version)) From ecda7ba137af7493900e965cbdd03cd7309f6fb0 Mon Sep 17 00:00:00 2001 From: Charlotte Wickham Date: Mon, 21 Oct 2024 13:41:31 -0700 Subject: [PATCH 5/6] Update listing --- tools/release-notes.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/release-notes.R b/tools/release-notes.R index fb72e3da41..c30852200f 100644 --- a/tools/release-notes.R +++ b/tools/release-notes.R @@ -81,18 +81,18 @@ readLines(prerelease_page) |> str_replace(aliases[2], aliases[3]) |> writeLines(prerelease_page) -# MANUALLY update listing ------------------------------------------------ +# Update listing ------------------------------------------------ old_abbr <- str_split(major_version, "\\.")[[1]] |> paste0(collapse = "") # Add new item to download-older listing in docs/download/index.qmd -cat("Please manually add a new item to the `download-older` listing in `docs/download/index.qmd`:\n") glue(' - id: version{ old_abbr } title: { old_release } - date: + date: { format(as.Date(old_release_date), "%Y/%m/%d") } path: https://github.com/quarto-dev/quarto-cli/releases/tag/{ old_release } changelog: "[Release Notes](changelog/{ major_version }/)" -') +') |> + cat(file = path(downloads, "_download-older.yml"), append = TRUE) From d4966f0ca0bbaf1e5f01ee5df5115269e415c487 Mon Sep 17 00:00:00 2001 From: Charlotte Wickham Date: Mon, 21 Oct 2024 13:46:33 -0700 Subject: [PATCH 6/6] Minor fixes --- tools/release-notes.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/release-notes.R b/tools/release-notes.R index c30852200f..e26360c839 100644 --- a/tools/release-notes.R +++ b/tools/release-notes.R @@ -88,10 +88,10 @@ old_abbr <- str_split(major_version, "\\.")[[1]] |> paste0(collapse = "") # Add new item to download-older listing in docs/download/index.qmd glue(' -- id: version{ old_abbr } +\n- id: version{ old_abbr } title: { old_release } date: { format(as.Date(old_release_date), "%Y/%m/%d") } - path: https://github.com/quarto-dev/quarto-cli/releases/tag/{ old_release } + path: https://github.com/quarto-dev/quarto-cli/releases/tag/v{ old_release } changelog: "[Release Notes](changelog/{ major_version }/)" ') |> cat(file = path(downloads, "_download-older.yml"), append = TRUE)