Skip to content

Commit fc1d198

Browse files
authored
Edit release notes template and edit scripts (#981)
Making the release scripts easier to use as well as automating more of the process.
1 parent 1ed7ef9 commit fc1d198

File tree

7 files changed

+140
-209
lines changed

7 files changed

+140
-209
lines changed

make_release/Readme.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,13 @@
7171
> - edit the `nu_release.nu` script to start again where it failed
7272
> - re-run the script
7373
74-
## 4. Publish the release note on the website
75-
> **Note**
76-
> the scripts have been written in such a way they can be run from anywhere
77-
78-
- [ ] inspect the merged PRs to write changelogs with `./make_release/release-note/list-merged-prs nushell/nushell`
79-
- [ ] reorder sections by priority, what makes the most sense to the user?
80-
- [ ] paste the output of `./make_release/release-note/list-merged-prs nushell/nushell --label pr:breaking-change --pretty --no-author` to the "*Breaking changes*" section
81-
- [ ] make sure breaking changes titles are clear enough
82-
- [ ] paste the output of `./make_release/release-note/get-full-changelog` to the "*Full changelog*" section
83-
- [ ] mark as *ready for review* when uploading to *crates.io*
74+
## 4. Publish the release notes on the website
75+
76+
- [ ] follow and finish the TODOs in the release notes file
77+
- [ ] mark as ready for review when uploading to crates.io
8478
- [ ] land when
8579
- **fully uploaded** to *crates.io*
86-
- **before** the *GitHub* release
80+
- **before** the GitHub release
8781
8882
## 5. Publish the release on *GitHub*
8983
- [ ] go to the draft release on the [release page](https://github.com/nushell/nushell/releases)

make_release/release-note/get-full-changelog

Lines changed: 0 additions & 27 deletions
This file was deleted.
File renamed without changes.

make_release/release-note/list-merged-prs

Lines changed: 0 additions & 100 deletions
This file was deleted.

make_release/release-note/notes.nu

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
def md-link [text: string, link: string] {
2+
$"[($text)]\(($link)\)"
3+
}
4+
5+
# List all merged PRs since the last release
6+
export def list-prs [
7+
repo: string = 'nushell/nushell' # the name of the repo, e.g. 'nushell/nushell'
8+
--since: datetime # list PRs on or after this date (defaults to 4 weeks ago if `--milestone` is not provided)
9+
--milestone: string # only list PRs in a certain milestone
10+
--label: string # the PR label to filter by, e.g. 'good-first-issue'
11+
] {
12+
mut query_parts = []
13+
14+
if $since != null or $milestone == null {
15+
let date = $since | default ((date now) - 4wk) | format date '%Y-%m-%d'
16+
$query_parts ++= [ $'merged:>($date)' ]
17+
}
18+
19+
if $milestone != null {
20+
$query_parts ++= [ $'milestone:"($milestone)"' ]
21+
}
22+
23+
if $label != null {
24+
$query_parts ++= [ $'label:($label)' ]
25+
}
26+
27+
let query = $query_parts | str join ' '
28+
29+
(gh --repo $repo pr list --state merged
30+
--limit (inf | into int)
31+
--json author,title,number,mergedAt,url
32+
--search $query)
33+
| from json
34+
| sort-by mergedAt --reverse
35+
| update author { get login }
36+
}
37+
38+
# Format the output of `list-prs` as a markdown table
39+
export def pr-table [] {
40+
sort-by author number
41+
| update author { md-link $'@($in)' $'https://github.com/($in)' }
42+
| insert link {|pr| md-link $'#($pr.number)' $pr.url }
43+
| select author title link
44+
| to md
45+
}
46+
47+
const toc = '[[toc](#table-of-content)]'
48+
49+
# Generate and write the table of contents to a release notes file
50+
export def write-toc [file: path] {
51+
let lines = open $file | lines | each { str trim -r }
52+
53+
let content_start = 2 + (
54+
$lines
55+
| enumerate
56+
| where item == '# Table of contents'
57+
| first
58+
| get index
59+
)
60+
61+
let data = (
62+
$lines
63+
| range $content_start..
64+
| wrap line
65+
| insert level {
66+
get line | split chars | take while { $in == '#' } | length
67+
}
68+
)
69+
70+
let table_of_contents = (
71+
$data
72+
| where level in 1..=3
73+
| each {|header|
74+
let indent = '- ' | fill -w ($header.level * 2) -a right
75+
76+
let text = $header.line | str trim -l -c '#' | str trim -l
77+
let text = if $text ends-with $toc {
78+
$text | str substring ..<(-1 * ($toc | str length)) | str trim -r
79+
} else {
80+
$text
81+
}
82+
83+
let link = (
84+
$text
85+
| str replace -a '`' ''
86+
| str replace -a ' ' '-'
87+
| str replace -a -r '--+' '-'
88+
)
89+
90+
$"($indent)[_($text)_]\(#($link)-toc\)"
91+
}
92+
)
93+
94+
let content = $data | each {
95+
if $in.level in 1..=3 and not ($in.line ends-with $toc) {
96+
$'($in.line) ($toc)'
97+
} else {
98+
$in.line
99+
}
100+
}
101+
102+
[
103+
...($lines | range ..<$content_start)
104+
...$table_of_contents
105+
...$content
106+
]
107+
| save -r -f $file
108+
}

make_release/release-note/template.md

Lines changed: 27 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ excerpt: Today, we're releasing version {{VERSION}} of Nu. This release adds...
77
---
88
<!-- TODO: complete the excerpt above -->
99

10-
# Nushell {{VERSION}}
10+
<!-- NOTE: start from the TODO all the way at the bottom (and sort of work your way up) -->
1111

12-
Nushell, or Nu for short, is a new shell that takes a modern, structured approach to your command line. It works seamlessly with the data from your filesystem, operating system, and a growing number of file formats to make it easy to build powerful command line pipelines.
12+
# Nushell {{VERSION}}
1313

1414
<!-- TODO: write this excerpt -->
1515
Today, we're releasing version {{VERSION}} of Nu. This release adds...
@@ -21,33 +21,11 @@ Nu {{VERSION}} is available as [pre-built binaries](https://github.com/nushell/n
2121
As part of this release, we also publish a set of optional plugins you can install and use with Nu. To install, use `cargo install nu_plugin_<plugin name>`.
2222

2323
# Table of contents
24-
- [_Highlights and themes of this release_](#highlights-and-themes-of-this-release-toc)
25-
- [_Changes_](#changes-toc)
26-
- [_Additions_](#additions-toc)
27-
- [_Breaking changes_](#breaking-changes-toc)
28-
- [_Deprecations_](#deprecations-toc)
29-
- [_Removals_](#removals-toc)
30-
- [_Bug fixes and other changes_](#bug-fixes-and-other-changes-toc)
31-
- [_Notes for plugin developers_](#notes-for-plugin-developers-toc)
32-
- [_Hall of fame_](#hall-of-fame-toc)
33-
- [_Full changelog_](#full-changelog-toc)
34-
<!-- TODO: please add links to the other sections here
35-
36-
the following command should help pre-generate a great deal of the table of content.
37-
be careful with the format and false-positives :wink:
38-
```nushell
39-
rg '^#+ ' blog/...
40-
| lines
41-
| each {
42-
str replace '# ' '- '
43-
| str replace --all '#' ' '
44-
| str replace --regex '- (.*)' '- [_$1_](#$1-toc)'
45-
}
46-
| to text
47-
```
48-
-->
4924

50-
# Highlights and themes of this release [[toc](#table-of-content)]
25+
<!-- TODO: once all the content below is finished and committed, `use nu_scripts/make_release/release-note/notes.nu *` and run `write-toc $this_file`. -->
26+
27+
# Highlights and themes of this release
28+
5129
<!-- NOTE: if you wanna write a section about a breaking change, when it's a very important one,
5230
please add the following snippet to have a "warning" banner :)
5331
> see [an example](https://www.nushell.sh/blog/2023-09-19-nushell_0_85_0.html#pythonesque-operators-removal)
@@ -62,60 +40,38 @@ As part of this release, we also publish a set of optional plugins you can insta
6240
for the list of available *containers*
6341
-->
6442

65-
# Changes [[toc](#table-of-content)]
43+
# Changes
6644

67-
## Additions [[toc](#table-of-content)]
45+
## Additions
6846

69-
## Breaking changes [[toc](#table-of-content)]
47+
## Breaking changes
7048

71-
## Deprecations [[toc](#table-of-content)]
49+
## Deprecations
7250

73-
## Removals [[toc](#table-of-content)]
51+
## Removals
7452

75-
## Bug fixes and other changes [[toc](#table-of-content)]
53+
## Bug fixes and other changes
7654

77-
<!-- NOTE: to start investigating the contributions of last release, i like to list them all in a raw table.
78-
to achieve this, one can use the [`list-merged-prs` script from `nu_scripts`](https://github.com/nushell/nu_scripts/blob/main/make_release/release-note/list-merged-prs)
79-
as follows:
55+
# Notes for plugin developers
8056

81-
```nushell
82-
use ./make_release/release-note/list-merged-prs
83-
use std clip
57+
# Hall of fame
8458

85-
let last_release_date = ^gh api /repos/nushell/nushell/releases
86-
| from json
87-
| into datetime published_at
88-
| get published_at
89-
| sort
90-
| last
59+
Thanks to all the contributors below for helping us solve issues, improve documentation, refactor code, and more! :pray:
9160

92-
let prs = list-merged-prs nushell/nushell $last_release_date
93-
| sort-by mergedAt
94-
| update url {|it| $"[#($it.number)]\(($it.url)\)" }
95-
| update author { $"[@($in)]\(https://github.com/($in)\)" }
96-
| select author title url
97-
| rename -c {url: pr}
98-
| to md --pretty
99-
100-
$prs | to md --pretty | clip
101-
```
102-
-->
103-
104-
# Notes for plugin developers [[toc](#table-of-content)]
105-
106-
# Hall of fame [[toc](#table-of-content)]
107-
108-
Thanks to all the contributors below for helping us solve issues and improve documentation :pray:
109-
110-
| author | title | url |
61+
| author | title | link |
11162
| ------------------------------------ | ----------- | ------------------------------------------------------- |
11263
| [@author](https://github.com/author) | ... | [#12345](https://github.com/nushell/nushell/pull/12345) |
11364

114-
# Full changelog [[toc](#table-of-content)]
65+
# Full changelog
66+
11567
<!-- TODO:
116-
paste the output of
117-
```nu
118-
./make_release/release-note/get-full-changelog
119-
```
120-
here
68+
- `use nu_scripts/make_release/release-note/notes.nu *`
69+
- run `list-prs --milestone v{{VERSION}} | pr-table`
70+
- paste the output here
71+
72+
Afterwards, go through each PR and clasify it as one of the following:
73+
- A user-facing change. These PRs should go into the `# Changes` section.
74+
- A plugin-facing change. These PRs should go in `# Notes for plugin developers`. Some plugin-facing changes might also be a user-facing change and vice versa.
75+
- A documentation improvement, error message improvement, refactoring PR, clippy fix, typo fix, etc. These PRs go into the `# Hall of fame`. You can just copy the table row in this section and paste it to the `# Hall of fame` section above. Note that major refactorings may warrant a section in `# Highlights`.
76+
- Dependabot PRs and version bumps should be ignored. They will only be mentioned in `# Full changelog`.
12177
-->

0 commit comments

Comments
 (0)