-
Notifications
You must be signed in to change notification settings - Fork 1
/
types_github.go
77 lines (69 loc) 路 2.2 KB
/
types_github.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package types
import (
"sort"
"strings"
"time"
"golang.org/x/mod/semver"
)
type GithubRelease struct {
TagName string `json:"tag_name"`
Name string `json:"name"`
Assets []Asset `json:"assets"`
Body string `json:"body"`
}
type Asset struct {
URL string `json:"url"`
ID int `json:"id"`
NodeID string `json:"node_id"`
Name string `json:"name"`
Label interface{} `json:"label"`
Uploader struct {
Login string `json:"login"`
ID int `json:"id"`
NodeID string `json:"node_id"`
AvatarURL string `json:"avatar_url"`
GravatarID string `json:"gravatar_id"`
URL string `json:"url"`
HTMLURL string `json:"html_url"`
FollowersURL string `json:"followers_url"`
FollowingURL string `json:"following_url"`
GistsURL string `json:"gists_url"`
StarredURL string `json:"starred_url"`
SubscriptionsURL string `json:"subscriptions_url"`
OrganizationsURL string `json:"organizations_url"`
ReposURL string `json:"repos_url"`
EventsURL string `json:"events_url"`
ReceivedEventsURL string `json:"received_events_url"`
Type string `json:"type"`
SiteAdmin bool `json:"site_admin"`
} `json:"uploader"`
ContentType string `json:"content_type"`
State string `json:"state"`
Size int `json:"size"`
DownloadCount int `json:"download_count"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
BrowserDownloadURL string `json:"browser_download_url"`
}
type GithubTags []GithubTag
func (ght GithubTags) GetLatest() *GithubTag {
sort.Slice(ght, func(i, j int) bool {
return semver.Compare(ght[i].Name, ght[j].Name) > 0
})
for _, tag := range ght {
if semver.IsValid(tag.Name) && !strings.Contains(tag.Name, "-") {
return &tag
}
}
return nil
}
type GithubTag struct {
Name string `json:"name"`
ZipballURL string `json:"zipball_url"`
TarballURL string `json:"tarball_url"`
Commit struct {
Sha string `json:"sha"`
URL string `json:"url"`
} `json:"commit"`
NodeID string `json:"node_id"`
}