Skip to content

Commit

Permalink
enhance logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Songmu committed May 18, 2017
1 parent cc81c88 commit 4df20d4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions cmd/mackerel-github-release/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"os/exec"
"path/filepath"
"sort"
"time"

"github.com/Songmu/retry"
Expand Down Expand Up @@ -68,6 +69,7 @@ func run(argv []string) int {
log.Printf("failed to unmarshal `gobump show`'s output: %+v\n", err)
return exitError
}
log.Printf("Start uploading files to GitHub Releases. version: %s, staging: %t, dry-run: %t\n", v.Version, *staging, *dryRun)
err = uploadToGithubRelease(proj, v.Version, *staging, *dryRun)
if err != nil {
log.Printf("error occured while uploading artifacts to github: %+v\n", err)
Expand All @@ -76,7 +78,7 @@ func run(argv []string) int {
return exitOK
}

var errAlreadyReleased = fmt.Errorf("the release of this version(%s) has already existed at GitHub Relase, so skip the process\n")
var errAlreadyReleased = fmt.Errorf("the release of this version has already existed at GitHub Relase, so skip the process")

func uploadToGithubRelease(proj *github.Project, releaseVer string, staging, dryRun bool) error {
tag := "staging"
Expand All @@ -94,7 +96,7 @@ func uploadToGithubRelease(proj *github.Project, releaseVer string, staging, dry
err = handleOldRelease(octoCli, owner, repo, tag, staging, dryRun)
if err != nil {
if err == errAlreadyReleased {
log.Printf(err.Error(), tag)
log.Printf("%s. version: %s\n", err, tag)
return nil
}
return err
Expand All @@ -105,6 +107,11 @@ func uploadToGithubRelease(proj *github.Project, releaseVer string, staging, dry
if err != nil {
return errors.Wrap(err, "error occured while collecting releasing assets")
}
sort.Strings(assets)
log.Println("uploading following files:")
for _, f := range assets {
log.Println(f)
}

host, err := github.CurrentConfig().PromptForHost(proj.Host)
if err != nil {
Expand Down Expand Up @@ -134,6 +141,7 @@ func uploadToGithubRelease(proj *github.Project, releaseVer string, staging, dry
})
}
}
log.Printf("Upload done. version: %s, staging: %t, dry-run: %t\n", releaseVer, staging, dryRun)
return nil
}

Expand Down

0 comments on commit 4df20d4

Please sign in to comment.