release create: Add --note-file flag to read release notes from a file (#678)

Add  a `--note-file` argument to pass a file with multi-line release notes instead of trying to pass as an argument using `--note`.

Co-authored-by: Lunny Xiao <lunny@noreply.gitea.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/gitea/tea/pulls/678
Reviewed-by: Lunny Xiao <lunny@noreply.gitea.com>
Co-authored-by: Nithin Philips <nithin@nithinphilips.com>
Co-committed-by: Nithin Philips <nithin@nithinphilips.com>
This commit is contained in:
Nithin Philips 2025-01-08 05:00:21 +00:00 committed by Lunny Xiao
parent 54b3f8e5b2
commit f3fe2a0532
2 changed files with 18 additions and 2 deletions

View File

@ -43,6 +43,11 @@ var CmdReleaseCreate = cli.Command{
Aliases: []string{"n"},
Usage: "Release notes",
},
&cli.StringFlag{
Name: "note-file",
Aliases: []string{"f"},
Usage: "Release notes file name. If set, --note is ignored.",
},
&cli.BoolFlag{
Name: "draft",
Aliases: []string{"d"},
@ -73,15 +78,24 @@ func runReleaseCreate(cmd *cli.Context) error {
tag = cmd.Args().First()
}
notestring := ctx.String("note")
notefile := ctx.String("note-file")
if notefile != "" {
notebytes, err := os.ReadFile(notefile)
if err != nil {
return fmt.Errorf("unable to read the note file")
}
notestring = string(notebytes)
}
release, resp, err := ctx.Login.Client().CreateRelease(ctx.Owner, ctx.Repo, gitea.CreateReleaseOption{
TagName: tag,
Target: ctx.String("target"),
Title: ctx.String("title"),
Note: ctx.String("note"),
Note: notestring,
IsDraft: ctx.Bool("draft"),
IsPrerelease: ctx.Bool("prerelease"),
})
if err != nil {
if resp != nil && resp.StatusCode == http.StatusConflict {
return fmt.Errorf("There already is a release for this tag")

View File

@ -737,6 +737,8 @@ Create a release
**--note, -n**="": Release notes
**--note-file, -f**="": Release notes file name. If set, --note is ignored.
**--output, -o**="": Output format. (simple, table, csv, tsv, yaml, json)
**--prerelease, -p**: Is a pre-release