forked from justwatchcom/github-releases-notifier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.go
38 lines (32 loc) · 1.02 KB
/
release.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
package main
import (
"net/url"
"strings"
"time"
)
// Release of a repository tagged via GitHub.
type Release struct {
ID string
Name string
Description string
URL url.URL
PublishedAt time.Time
IsDraft bool
IsPrerelease bool
}
// IsReleaseCandidate returns true if the release name hints at an RC release.
func (r Release) IsReleaseCandidate() bool {
return strings.Contains(strings.ToLower(r.Name), "-rc")
}
// IsBeta returns true if the release name hints at a beta version release.
func (r Release) IsBeta() bool {
return strings.Contains(strings.ToLower(r.Name), "beta")
}
// IsDevelopment returns true if the release name hints at a development version release.
func (r Release) IsDevelopment() bool {
return strings.Contains(strings.ToLower(r.Name), "dev")
}
// IsNonstable returns true if one of the non-stable release-checking functions return true.
func (r Release) IsNonstable() bool {
return r.IsReleaseCandidate() || r.IsBeta() || r.IsDevelopment() || r.IsDraft || r.IsPrerelease
}