Skip to content

Commit 937b2cd

Browse files
authored
Merge pull request #1386 from quarto-dev/issue/10277
Script to automate release notes
2 parents d2e9d52 + d4966f0 commit 937b2cd

File tree

3 files changed

+122
-26
lines changed

3 files changed

+122
-26
lines changed

docs/download/_download-older.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,25 @@
33
- id: version10
44
title: v1.0.38
55
date: 2022/08/04
6-
url: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.0.38
6+
path: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.0.38
7+
- id: version11
8+
title: v1.1.189
9+
date: 2022/09/04
10+
path: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.1.189
11+
changelog: "[Release Notes](changelog/1.1/)"
12+
- id: version12
13+
title: v1.2.475
14+
date: 2023/03/22
15+
path: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.2.475
16+
changelog: "[Release Notes](changelog/1.2/)"
17+
- id: version13
18+
title: v1.3.450
19+
date: 2023/08/23
20+
path: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.3.450
21+
changelog: "[Release Notes](changelog/1.3/)"
22+
- id: version14
23+
title: v1.4.557
24+
date: 2024/06/27
25+
path: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.4.557
26+
changelog: "[Release Notes](changelog/1.4/)"
27+

docs/download/index.qmd

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,8 @@ editor: source
2020
image: /images/hero_right.png
2121
listing:
2222
id: download-older
23-
contents:
24-
- id: version14
25-
title: v1.4.557
26-
date: 2024/06/27
27-
path: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.4.557
28-
changelog: "[Release Notes](changelog/1.4/)"
29-
- id: version13
30-
title: v1.3.450
31-
date: 2023/08/23
32-
path: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.3.450
33-
changelog: "[Release Notes](changelog/1.3/)"
34-
- id: version12
35-
title: v1.2.475
36-
date: 2023/03/22
37-
path: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.2.475
38-
changelog: "[Release Notes](changelog/1.2/)"
39-
- id: version11
40-
title: v1.1.189
41-
date: 2022/09/04
42-
path: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.1.189
43-
changelog: "[Release Notes](changelog/1.1/)"
44-
- id: version10
45-
title: v1.0.38
46-
date: 2022/08/04
47-
path: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.0.38
23+
contents: /_download-older.yml
24+
sort: "date desc"
4825
fields:
4926
- title
5027
- changelog

tools/release-notes.R

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
library(fs)
2+
library(stringr)
3+
library(glue)
4+
library(jsonlite)
5+
library(gh)
6+
7+
downloads <- path("docs", "download")
8+
9+
# Current versions -------------------------------------------------------
10+
11+
# Based on updated download files
12+
new_release <- read_json(path(downloads, "_download.json"))$version
13+
new_prerelease <- read_json(path(downloads, "_prerelease.json"))$version
14+
15+
# Old version from Git history -------------------------------------------
16+
17+
# Need version at two commits ago
18+
previous_commit <- gh("https://api.github.com/repos/:owner/:repo/commits",
19+
owner = "quarto-dev", repo = "quarto-web",
20+
path = "docs/download/_download.json",
21+
per_page = 2)
22+
23+
previous_commit_ref <- previous_commit[[2]]$sha
24+
25+
previous_contents <- gh("/repos/{owner}/{repo}/contents/{path}",
26+
owner = "quarto-dev", repo = "quarto-web",
27+
path = "docs/download/_download.json",
28+
ref = previous_commit_ref,
29+
.accept = "application/vnd.github.raw+json")
30+
previous_contents_json <- parse_json(previous_contents$message)
31+
32+
old_release <- previous_contents_json$version
33+
old_release_date <- previous_contents_json$created
34+
35+
# Version numbers
36+
extract_major <- function(x){
37+
str_extract(x, "(\\d+)\\.(\\d+)")
38+
}
39+
40+
new_release_major <- extract_major(new_release)
41+
new_prerelease_major <- extract_major(new_prerelease)
42+
major_version <- extract_major(old_release)
43+
44+
cat("Release:", old_release, "->", new_release, "\n")
45+
cat("Prerelease:", major_version, "->", new_prerelease_major, "\n")
46+
47+
# Create new changelog content -------------------------------------------
48+
49+
changelog_url <- paste0("https://github.com/quarto-dev/quarto-cli/releases/download/v",
50+
old_release, "/changelog.md")
51+
changelog_dir <- dir_create(path(downloads, "changelog", major_version))
52+
53+
download_status <- download.file(changelog_url, path(changelog_dir,
54+
"_changelog", ext = "md"))
55+
stopifnot(!download_status)
56+
57+
glue("
58+
---
59+
title: {major_version} Release Notes
60+
format: html
61+
---
62+
63+
{{{{< include _changelog.md >}}}}
64+
") |>
65+
writeLines(path(changelog_dir, "index", ext = "qmd"))
66+
67+
# Increment versions of aliases ------------------------------------------
68+
69+
release_page <- path(downloads, "release", ext = "qmd")
70+
prerelease_page <- path(downloads, "prerelease", ext = "qmd")
71+
72+
aliases <- paste0("changelog/",
73+
c(major_version, new_release_major, new_prerelease_major),
74+
"/")
75+
76+
readLines(release_page) |>
77+
str_replace(aliases[1], aliases[2]) |>
78+
writeLines(release_page)
79+
80+
readLines(prerelease_page) |>
81+
str_replace(aliases[2], aliases[3]) |>
82+
writeLines(prerelease_page)
83+
84+
# Update listing ------------------------------------------------
85+
86+
old_abbr <- str_split(major_version, "\\.")[[1]] |> paste0(collapse = "")
87+
88+
# Add new item to download-older listing in docs/download/index.qmd
89+
90+
glue('
91+
\n- id: version{ old_abbr }
92+
title: { old_release }
93+
date: { format(as.Date(old_release_date), "%Y/%m/%d") }
94+
path: https://github.com/quarto-dev/quarto-cli/releases/tag/v{ old_release }
95+
changelog: "[Release Notes](changelog/{ major_version }/)"
96+
') |>
97+
cat(file = path(downloads, "_download-older.yml"), append = TRUE)
98+

0 commit comments

Comments
 (0)