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

Merged
merged 4 commits into from
Jun 18, 2025

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.

@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 <[email protected]>
@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.

@wxiaoguang wxiaoguang force-pushed the api-release-support-annotated-tags branch from 97feabd to f91fb9d Compare June 18, 2025 02:58
kemzeb and others added 2 commits June 18, 2025 10:59
This adds a new field, "tag_message", that represents the message
of the annotated tag.
@wxiaoguang wxiaoguang force-pushed the api-release-support-annotated-tags branch from f91fb9d to 431366c Compare June 18, 2025 02:59
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jun 18, 2025
@wxiaoguang wxiaoguang added this to the 1.25.0 milestone Jun 18, 2025
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Jun 18, 2025
@lunny lunny enabled auto-merge (squash) June 18, 2025 05:06
@lunny lunny merged commit 416ff1f into go-gitea:main Jun 18, 2025
26 checks passed
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Jun 18, 2025
@wxiaoguang wxiaoguang added the type/enhancement An improvement of existing functionality label Jun 18, 2025
zjjhot added a commit to zjjhot/gitea that referenced this pull request Jun 19, 2025
* giteaofficial/main:
  [skip ci] Updated translations via Crowdin
  Upgrade `gopls` to v0.19.0, add `make fix` (go-gitea#34772)
  Refactor packages (func name & UI) (go-gitea#34773)
  Fix remaining issues after `gopls modernize` formatting (go-gitea#34771)
  Fix some package registry problems (go-gitea#34759)
  Fix incorrect cli default values and default command (go-gitea#34765)
  Support annotated tags when using create release API (go-gitea#31840)
  when using rules to delete packages, remove unclean bugs (go-gitea#34632)
  Fix readme path and markdown link paste (go-gitea#34755)
@kemzeb kemzeb deleted the api-release-support-annotated-tags branch June 19, 2025 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code type/enhancement An improvement of existing functionality
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