Files
Shivansh Gargandsilverwind a5201dc427 feat(release): allow setting a release as the latest (#40214)
Gitea picks the latest release by commit date, while GitHub keeps an
explicit pointer, so repositories migrated from GitHub could show a
different latest release than their source. Fixes
https://github.com/go-gitea/gitea/issues/35273.

- Add a "Set as Latest Release" checkbox and GitHub's `make_latest` API
option. Without them, the newest stable release by commit date stays the
latest.
- Migrations from GitHub and Gitea carry over the source's latest
release.
- Migrated releases are dated by their commit like native ones, and
equally dated ones keep the source's order.

<img width="355" height="122" alt="Set as Latest Release checkbox"
src="https://github.com/user-attachments/assets/d35f5324-7ae0-4e9f-b73c-d3c90496fb00"
/>

---------

Co-authored-by: silverwind <me@silverwind.io>
2026-11-06 08:23:13 +00:00

92 lines
3.2 KiB
Go

// Copyright 2016 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package structs
import (
"time"
)
// Release represents a repository release
type Release struct {
// The unique identifier of the release
ID int64 `json:"id"`
// The name of the git tag associated with the release
TagName string `json:"tag_name"`
// The target commitish for the release
Target string `json:"target_commitish"`
// The display title of the release
Title string `json:"name"`
// The release notes or description
Note string `json:"body"`
// The API URL of the release
URL string `json:"url"`
// The HTML URL to view the release
HTMLURL string `json:"html_url"`
// The URL to download the tarball archive
TarURL string `json:"tarball_url"`
// The URL to download the zip archive
ZipURL string `json:"zipball_url"`
// The URL template for uploading release assets
UploadURL string `json:"upload_url"`
// Whether the release is a draft
IsDraft bool `json:"draft"`
// Whether the release is a prerelease
IsPrerelease bool `json:"prerelease"`
// swagger:strfmt date-time
CreatedAt time.Time `json:"created_at"`
// swagger:strfmt date-time
PublishedAt *time.Time `json:"published_at"`
// The user who published the release
Publisher *User `json:"author"`
// The files attached to the release
Attachments []*Attachment `json:"assets"`
}
// swagger:enum MakeLatest
type MakeLatest string
const (
MakeLatestTrue MakeLatest = "true"
MakeLatestFalse MakeLatest = "false"
MakeLatestLegacy MakeLatest = "legacy"
)
// CreateReleaseOption options when creating a release
type CreateReleaseOption struct {
// required: true
TagName string `json:"tag_name" binding:"Required"`
// The message for the git tag
TagMessage string `json:"tag_message"`
// The target commitish for the release
Target string `json:"target_commitish"`
// The display title of the release
Title string `json:"name"`
// The release notes or description
Note string `json:"body"`
// Whether to create the release as a draft
IsDraft bool `json:"draft"`
// Whether to mark the release as a prerelease
IsPrerelease bool `json:"prerelease"`
// "true" sets the release as the latest, "false" keeps the current latest, "legacy" returns to the newest stable release by date. If omitted, a newly published release becomes the latest only if it is the newest by date
MakeLatest MakeLatest `json:"make_latest" binding:"In(,true,false,legacy)"`
}
// EditReleaseOption options when editing a release
type EditReleaseOption struct {
// The new name of the git tag
TagName string `json:"tag_name"`
// The new target commitish for the release
Target string `json:"target_commitish"`
// The new display title of the release
Title string `json:"name"`
// The new release notes or description
Note string `json:"body"`
// Whether to change the draft status
IsDraft *bool `json:"draft"`
// Whether to change the prerelease status
IsPrerelease *bool `json:"prerelease"`
// "true" sets the release as the latest, "false" keeps the current latest, "legacy" returns to the newest stable release by date. If omitted, a newly published release becomes the latest only if it is the newest by date
MakeLatest MakeLatest `json:"make_latest" binding:"In(,true,false,legacy)"`
}