1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-01 22:57:46 +00:00

REFACTOR: rewrite the release note scripts (#525)

* move "create release PR" script to `make_release/release-note/`

* move "since last release" script to `make_release/release-note/`

* add a script to list contributions for the release note

* rewrite `since_last_release` to use `list-merged-prs`

This commit also makes the script executable.

* update the `make_release/` readme

* add the commands to run to the release note template

* rename `since_last_release.nu` to `get-full-changelog`

* move the release note PR template to a standalone file

* add another section to inspect Nushell PRs to write changelogs

* fix the name of the command inside it's own doc
This commit is contained in:
Antoine Stevan 2023-06-09 22:26:46 +02:00 committed by GitHub
parent 039930b4e4
commit 2e46f056c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 170 additions and 96 deletions

View file

@ -0,0 +1,95 @@
#!/usr/bin/env nu
use std log
def open-pr [
repo: path
remote: string
pr: record<
branch: string
title: string
body: string
>
] {
cd $repo
gh repo set-default $remote
log info "mock up pr"
(
gh pr create
--head $pr.branch
--base main
--title $pr.title
--body $pr.body
--draft
)
}
def clean [repo: path] {
log info "removing the repo"
rm -rf $repo
}
# open the release note PR interactively
#
# # Example
# [this PR](https://github.com/nushell/nushell.github.io/pull/916) has been created with the script
# > ./make_release/release-note/create-pr 0.81 2023-06-06
def main [
version: string # the version of the release, e.g. `0.80`
date: datetime # the date of the upcoming release, e.g. `2023-05-16`
] {
let repo = ($nu.temp-path | path join (random uuid))
let branch = $"release-notes-($version)"
let blog_path = (
$repo | path join "blog" $"($date | date format "%Y-%m-%d")-nushell_($version | str replace --all --string '.' '_').md"
)
let title = $"Release notes for `($version)`"
let body = $"Please add your new features and breaking changes to the release notes
by opening PRs against the `release-notes-($version)` branch."
log info "setting up nushell.github.io repo"
git clone git@github.com:nushell/nushell.github.io $repo --origin nushell --branch main --single-branch
log info "creating release branch"
git -C $repo checkout -b $branch nushell/main
log info "creating release note from template"
$env.CURRENT_FILE
| path dirname
| path join "template.md"
| open
| str replace --all --string "{{VERSION}}" $version
| save --force $blog_path
log info "commiting release note"
git -C $repo add $blog_path
git -C $repo commit -m $"($title)\n\n($body)"
log info "pushing release note to nushell"
git -C $repo push nushell $branch
let out = (do -i { gh auth status } | complete)
if $out.exit_code != 0 {
clean $repo
let pr_url = $"https://github.com/nushell/nushell.github.io/compare/($branch)?expand=1"
error make --unspanned {
msg: ([
$out.stderr
$"please open the PR manually from a browser (ansi blue_underline)($pr_url | ansi link --text 'here')(ansi reset)"
] | str join "\n")
}
}
log info "opening pull request"
open-pr $repo nushell/nushell.github.io {
branch: $"nushell:($branch)"
title: $title
body: $body
}
clean $repo
}

View file

@ -0,0 +1,25 @@
#!/usr/bin/env nu
def main [] {
let list_merged_prs_script = (
$env.CURRENT_FILE | path dirname | path join "list-merged-prs"
)
let changelogs = [
[title repo];
[Nushell nushell/nushell]
[Extension nushell/vscode-nushell-lang]
[Documentation nushell/nushell.github.io]
[Nu_Scripts nushell/nu_scripts]
[Reedline reedline]
]
$changelogs | each {|changelog|
[
$"## ($changelog.title)"
(^$list_merged_prs_script $changelog.repo --pretty)
] | str join "\n"
}
| str join "\n\n"
}

View file

@ -0,0 +1,71 @@
#!/usr/bin/env nu
def md-link [
text: string
link: string
] {
$"[($text)]\(($link)\)"
}
# list all merged PRs since last release
def main [
repo: string # the name of the repo, e.g. `nushell/nushell`
date?: datetime # the date of the last release (default to 3 weeks ago, excluded)
--label: string # the label to filter the PRs by, e.g. `good-first-issue`
--pretty: bool # pretty-print for the MarkDown release not
--no-author: bool # do not group the contributions by author
] {
let date = (
if $date == null { (date now) - 3wk + 1day } else { $date }
| date format "%Y-%m-%d"
)
let query = if $label == null {
$"merged:>($date)"
} else {
$"merged:>($date) label:($label)"
}
let prs = (
gh --repo $repo pr list
--state merged
--limit (inf | into int)
--json author,title,number,mergedAt,url
--search $query
| from json
| sort-by mergedAt --reverse
| update author { get login }
)
if $pretty {
if $no_author {
return (
$prs | each {|pr|
let link = (md-link $pr.number $pr.url)
$"- ($link) ($pr.title)"
}
| str join "\n"
)
}
return (
$prs
| group-by author
| transpose author prs
| each {|line|
let author = (md-link $line.author $"https://github.com/($line.author)")
$"- ($author) created" | append (
$line.prs | each {|pr|
let link = (md-link $pr.title $pr.url)
$" - ($link)"
}
)
| str join "\n"
}
| to text
)
}
$prs
}

View file

@ -0,0 +1,45 @@
---
title: Nushell {{VERSION}}
author: The Nu Authors
author_site: https://twitter.com/nu_shell
author_image: https://www.nushell.sh/blog/images/nu_logo.png
excerpt: Today, we're releasing version {{VERSION}} of Nu. This release adds...
---
# Nushell {{VERSION}}
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.
Today, we're releasing version {{VERSION}} of Nu. This release adds...
<!-- more -->
# Where to get it
Nu {{VERSION}} is available as [pre-built binaries](https://github.com/nushell/nushell/releases/tag/{{VERSION}}.0) or from [crates.io](https://crates.io/crates/nu). If you have Rust installed you can install it using `cargo install nu`.
NOTE: The optional dataframe functionality is available by `cargo install nu --features=dataframe`.
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>`.
# Themes of this release / New features
## New theme ([author](https://github.com/nushell/nushell/pulls))
# Breaking changes
{{ TODO
paste the output of
```nu
./make_release/release-note/list-merged-prs nushell/nushell --label breaking-change --pretty --no-author
```
here
}}
# Full changelog
{{ TODO
paste the output of
```nu
./make_release/release-note/get-full-changelog
```
here
}}