Moved struct into separate file, fixed bug for nonexistant releases

release/0.4
Thomas Boerger 9 years ago
parent a7c989263e
commit 684dcb0137
  1. 39
      main.go
  2. 8
      types.go

@ -15,23 +15,23 @@ import (
"golang.org/x/oauth2"
)
type Params struct {
BaseUrl string `json:"base_url"`
UploadUrl string `json:"upload_url"`
APIKey string `json:"api_key"`
Files []string `json:"files"`
}
var (
build string
buildDate string
)
func main() {
fmt.Printf("Drone GitHub Release Plugin built at %s\n", buildDate)
workspace := drone.Workspace{}
repo := drone.Repo{}
build := drone.Build{}
vargs := Params{}
plugin.Param("workspace", &workspace)
plugin.Param("repo", &repo)
plugin.Param("build", &build)
plugin.Param("vargs", &vargs)
plugin.Param("workspace", &workspace)
plugin.MustParse()
if build.Event != "tag" {
@ -41,10 +41,6 @@ func main() {
return
}
if len(workspace.Path) != 0 {
os.Chdir(workspace.Path)
}
if len(vargs.BaseUrl) == 0 {
vargs.BaseUrl = "https://api.github.com/"
} else {
@ -68,6 +64,10 @@ func main() {
return
}
if len(workspace.Path) != 0 {
os.Chdir(workspace.Path)
}
files := make([]string, 0)
for _, glob := range vargs.Files {
@ -116,7 +116,7 @@ func main() {
client.BaseURL = baseUrl
client.UploadURL = uploadUrl
release, releaseErr := retrieveRelease(
release, releaseErr := prepareRelease(
client,
repo.Owner,
repo.Name,
@ -145,31 +145,24 @@ func main() {
}
func prepareRelease(client *github.Client, owner string, repo string, tag string) (*github.RepositoryRelease, error) {
var release *github.RepositoryRelease
var releaseErr error
release, releaseErr = retrieveRelease(
release, _ := retrieveRelease(
client,
owner,
repo,
tag)
if releaseErr != nil {
return nil, releaseErr
}
if release != nil {
return release, nil
}
release, releaseErr = createRelease(
release, err := createRelease(
client,
owner,
repo,
tag)
if releaseErr != nil {
return nil, releaseErr
if err != nil {
return nil, err
}
if release != nil {

@ -0,0 +1,8 @@
package main
type Params struct {
BaseUrl string `json:"base_url"`
UploadUrl string `json:"upload_url"`
APIKey string `json:"api_key"`
Files []string `json:"files"`
}
Loading…
Cancel
Save