-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from vsoch/add/github-updater
Adding GitHub updater (for releases)
- Loading branch information
Showing
8 changed files
with
329 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package github | ||
|
||
import ( | ||
"encoding/json" | ||
"github.com/vsoch/uptodate/utils" | ||
"log" | ||
"time" | ||
) | ||
|
||
type Releases []struct { | ||
URL string `json:"url"` | ||
HTMLURL string `json:"html_url"` | ||
AssetsURL string `json:"assets_url"` | ||
UploadURL string `json:"upload_url"` | ||
TarballURL string `json:"tarball_url"` | ||
ZipballURL string `json:"zipball_url"` | ||
ID int `json:"id"` | ||
NodeID string `json:"node_id"` | ||
TagName string `json:"tag_name"` | ||
TargetCommitish string `json:"target_commitish"` | ||
Name string `json:"name"` | ||
Body string `json:"body"` | ||
Draft bool `json:"draft"` | ||
Prerelease bool `json:"prerelease"` | ||
CreatedAt time.Time `json:"created_at"` | ||
PublishedAt time.Time `json:"published_at"` | ||
Author 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:"author"` | ||
Assets []struct { | ||
URL string `json:"url"` | ||
BrowserDownloadURL string `json:"browser_download_url"` | ||
ID int `json:"id"` | ||
NodeID string `json:"node_id"` | ||
Name string `json:"name"` | ||
Label string `json:"label"` | ||
State string `json:"state"` | ||
ContentType string `json:"content_type"` | ||
Size int `json:"size"` | ||
DownloadCount int `json:"download_count"` | ||
CreatedAt time.Time `json:"created_at"` | ||
UpdatedAt time.Time `json:"updated_at"` | ||
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"` | ||
} `json:"assets"` | ||
} | ||
|
||
func GetReleases(name string) Releases { | ||
|
||
url := "https://api.github.com/repos/" + name + "/releases" | ||
|
||
headers := make(map[string]string) | ||
headers["Accept"] = "application/vnd.github.v3+json" | ||
response := utils.GetRequest(url, headers) | ||
|
||
// The response gets parsed into a spack package | ||
releases := Releases{} | ||
err := json.Unmarshal([]byte(response), &releases) | ||
if err != nil { | ||
log.Fatalf("Issue unmarshalling releases data structure\n") | ||
} | ||
return releases | ||
} |
Oops, something went wrong.