add codeberg releases
This commit is contained in:
1
internal/assets/static/icons/codeberg.svg
Normal file
1
internal/assets/static/icons/codeberg.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 4.233 4.233"><g style="opacity:1"><path d="M46.984 76.122a2.117 2.117 0 0 0-1.793 3.242l1.764-2.281c.013-.017.045-.017.057 0l.737.952h-.527l.011.042h.55l.155.201h-.648l.018.066h.68l.138.177h-.769l.024.085h.81l.123.158h-.889l.03.104h.938l.108.138h-1.009l.033.115h1.065l.099.128H47.56l.033.115h1.184a2.117 2.117 0 0 0-1.793-3.242m.644 3.37.033.115h.939q.047-.056.09-.115zm.068.243.032.115h.629a3 3 0 0 0 .125-.115zm.068.243.032.114h.212c.063-.036.121-.072.184-.114z" style="fill-opacity:1;stroke:none;stroke-width:.0660874;paint-order:markers fill stroke;stop-color:#000" transform="translate(-44.867 -75.99)"/></g></svg>
|
||||
|
After Width: | Height: | Size: 695 B |
39
internal/feed/codeberg.go
Normal file
39
internal/feed/codeberg.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package feed
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type codebergReleaseResponseJson struct {
|
||||
TagName string `json:"tag_name"`
|
||||
PublishedAt string `json:"published_at"`
|
||||
HtmlUrl string `json:"html_url"`
|
||||
}
|
||||
|
||||
func FetchLatestCodebergRelease(request *ReleaseRequest) (*AppRelease, error) {
|
||||
httpRequest, err := http.NewRequest(
|
||||
"GET",
|
||||
fmt.Sprintf(
|
||||
"https://codeberg.org/api/v1/repos/%s/releases/latest",
|
||||
request.Repository,
|
||||
),
|
||||
nil,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response, err := decodeJsonFromRequest[codebergReleaseResponseJson](defaultClient, httpRequest)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &AppRelease{
|
||||
Source: ReleaseSourceCodeberg,
|
||||
Name: request.Repository,
|
||||
Version: normalizeVersionFormat(response.TagName),
|
||||
NotesUrl: response.HtmlUrl,
|
||||
TimeReleased: parseRFC3339Time(response.PublishedAt),
|
||||
}, nil
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
type ReleaseSource string
|
||||
|
||||
const (
|
||||
ReleaseSourceCodeberg ReleaseSource = "codeberg"
|
||||
ReleaseSourceGithub ReleaseSource = "github"
|
||||
ReleaseSourceGitlab ReleaseSource = "gitlab"
|
||||
ReleaseSourceDockerHub ReleaseSource = "dockerhub"
|
||||
@@ -57,6 +58,8 @@ func FetchLatestReleases(requests []*ReleaseRequest) (AppReleases, error) {
|
||||
|
||||
func fetchLatestReleaseTask(request *ReleaseRequest) (*AppRelease, error) {
|
||||
switch request.Source {
|
||||
case ReleaseSourceCodeberg:
|
||||
return FetchLatestCodebergRelease(request)
|
||||
case ReleaseSourceGithub:
|
||||
return fetchLatestGithubRelease(request)
|
||||
case ReleaseSourceGitlab:
|
||||
|
||||
@@ -40,7 +40,6 @@ func (widget *Releases) Initialize() error {
|
||||
for _, repository := range widget.Repositories {
|
||||
parts := strings.SplitN(repository, ":", 2)
|
||||
var request *feed.ReleaseRequest
|
||||
|
||||
if len(parts) == 1 {
|
||||
request = &feed.ReleaseRequest{
|
||||
Source: feed.ReleaseSourceGithub,
|
||||
@@ -65,6 +64,11 @@ func (widget *Releases) Initialize() error {
|
||||
Source: feed.ReleaseSourceDockerHub,
|
||||
Repository: parts[1],
|
||||
}
|
||||
} else if parts[0] == string(feed.ReleaseSourceCodeberg) {
|
||||
request = &feed.ReleaseRequest{
|
||||
Source: feed.ReleaseSourceCodeberg,
|
||||
Repository: parts[1],
|
||||
}
|
||||
} else {
|
||||
return errors.New("invalid repository source " + parts[0])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user