From 6ec5cb77bd1b7fd6fb0070b611e6375b5e3d5574 Mon Sep 17 00:00:00 2001 From: Kemal Zebari Date: Thu, 15 Aug 2024 12:15:04 -0700 Subject: [PATCH] Support annotated tags when using create release API This adds a new field, "tag_message", that represents the message of the annotated tag. --- modules/structs/release.go | 1 + routers/api/v1/repo/release.go | 2 +- templates/swagger/v1_json.tmpl | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/structs/release.go b/modules/structs/release.go index c7378645c2..fac86ca7a2 100644 --- a/modules/structs/release.go +++ b/modules/structs/release.go @@ -33,6 +33,7 @@ type Release struct { type CreateReleaseOption struct { // required: true TagName string `json:"tag_name" binding:"Required"` + TagMessage string `json:"tag_message"` Target string `json:"target_commitish"` Title string `json:"name"` Note string `json:"body"` diff --git a/routers/api/v1/repo/release.go b/routers/api/v1/repo/release.go index ef587f6274..c9a0f33f12 100644 --- a/routers/api/v1/repo/release.go +++ b/routers/api/v1/repo/release.go @@ -246,7 +246,7 @@ func CreateRelease(ctx *context.APIContext) { IsTag: false, Repo: ctx.Repo.Repository, } - if err := release_service.CreateRelease(ctx.Repo.GitRepo, rel, nil, ""); err != nil { + if err := release_service.CreateRelease(ctx.Repo.GitRepo, rel, nil, form.TagMessage); err != nil { if repo_model.IsErrReleaseAlreadyExist(err) { ctx.Error(http.StatusConflict, "ReleaseAlreadyExist", err) } else if models.IsErrProtectedTagName(err) { diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 52d3754737..17bc1f2a05 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -20115,6 +20115,10 @@ "type": "boolean", "x-go-name": "IsPrerelease" }, + "tag_message": { + "type": "string", + "x-go-name": "TagMessage" + }, "tag_name": { "type": "string", "x-go-name": "TagName"