Skip to content

Support annotated tags when using create release API #31840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

kemzeb
Copy link
Member

@kemzeb kemzeb commented Aug 15, 2024

This adds a new field, "tag_message", that represents the message of the annotated tag.

Resolves #31835.

This adds a new field, "tag_message", that represents the message
of the annotated tag.
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Aug 15, 2024
@github-actions github-actions bot added modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code labels Aug 15, 2024
@kemzeb
Copy link
Member Author

kemzeb commented Aug 15, 2024

Currently we don't return the tag message in the response. We don't store the tag message in the Release model, so that would mean we would have to either:

  • Communicate to git in order to get this
  • Store the tag message in the database
  • Don't include it in the response

I looked to see what the other forges were doing, and it appears that GitLab doesn't expose a similar field in its API response. See here.

@lunny
Copy link
Member

lunny commented Aug 16, 2024

How about reuse body as tag message? This is a non-compatible API change with Github API v3 https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#create-a-release

@kemzeb
Copy link
Member Author

kemzeb commented Aug 16, 2024

Done, though the problems I see with this is that:

  • Both the release note and the tag message will be the same
  • You can't create lightweight tags if you have a release note

Not sure if these are potential problems

@lunny
Copy link
Member

lunny commented Aug 16, 2024

Looks like Github API doesn't support to create tag.

lunny pushed a commit that referenced this pull request Sep 12, 2024
A 500 status code was thrown when passing a non-existent target to the
create release API. This snapshot handles this error and instead throws
a 404 status code.

Discovered while working on #31840.
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request Sep 14, 2024
A 500 status code was thrown when passing a non-existent target to the
create release API. This snapshot handles this error and instead throws
a 404 status code.

Discovered while working on go-gitea#31840.
yp05327 pushed a commit that referenced this pull request Sep 17, 2024
Backport #31841 by @kemzeb

A 500 status code was thrown when passing a non-existent target to the
create release API. This snapshot handles this error and instead throws
a 404 status code.

Discovered while working on #31840.

Co-authored-by: Kemal Zebari <60799661+kemzeb@users.noreply.github.com>
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Sep 23, 2024
@lunny
Copy link
Member

lunny commented Sep 23, 2024

I noticed in web router, the msg is

		msg := ""
		if len(form.Title) > 0 && form.AddTagMsg {
			msg = form.Title + "\n\n" + form.Content
		}

Which has a different implementation between web and this API.

@kemzeb
Copy link
Member Author

kemzeb commented Sep 23, 2024

I'm still not sure if its desirable to have both the tag message and the release description be the same. I also experimented with the GitHub API, and there really doesn't seem to be a way to create an annotated tag with this endpoint (even when specifying the body field).

This does look like it has been a sought after feature though.

@wxiaoguang
Copy link
Contributor

TBH, I think the initial approach is right (adds a new field, "tag_message", that represents the message of the annotated tag).

The "Note" can't be reused, because the release note might be quite long, it is not the same as the tag's message.

@lunny
Copy link
Member

lunny commented Feb 2, 2025

How about reuse body as tag message? This is a non-compatible API change with Github API v3 docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#create-a-release

But that will create a non-compatible API with GH? Looks like GH doesn't have that field.

@techknowlogick
Copy link
Member

Annotated tags can also be quite long(see our tags as an example). Looking at the GH API they are using "body", is that something we could use to ensure our API is similarly compliant?

@wxiaoguang
Copy link
Contributor

How about reuse body as tag message? This is a non-compatible API change with Github API v3 docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#create-a-release

But that will create a non-compatible API with GH? Looks like GH doesn't have that field.

Do you mean that GitHub: "use body a release note" and "use body as tag message"?

@wxiaoguang
Copy link
Contributor

@kemzeb any conclusion?

@kemzeb
Copy link
Member Author

kemzeb commented Apr 21, 2025

@kemzeb any conclusion?

Looking back at this, I currently see the following approaches:

  • Use the tag_message field in order to create an annotated tag. For users that only want to use the GitHub-related fields I don't believe they would have any trouble. For users who also want to be able to have there release be an annotated tag they can specify tag_message. This is non-compliant to GitHub's API but similar to GitLab's API
  • Pass the body field as an argument to release_service.CreateRelease(), making the tag that's created into an annotated tag. This will create an annotated tag, where both the release's and tag's body will be the same. I would say that this is non-compliant to GitHub's API since our API will now always create an annotated tag when creating a release (where GitHub creates a lightweight tag)
  • Decide against allowing annotated tags being created using the release API and close the issue/PR

Not quite sure where we're leaning here but I'm open to other solutions

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Apr 25, 2025

I don't use these APIs, while at first glance, the tag_message approach seems the best one?

  • Use the tag_message field in order to create an annotated tag. similar to GitLab's API
  • It doesn't change existing API's behavior
  • The second body approach is non-compliant to GitHub's API either, so we don't need to worry about compatible or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/need 1 This PR needs approval from one additional maintainer to be merged. modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Creating a release via the API should allow for creating an annotated tag
5 participants