Skip to content

Commit

Permalink
Open release file in retry loop (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
afritzler authored Mar 15, 2021
1 parent 30f8b9d commit 861715c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,17 @@ func (c *Client) uploadReleaseAsset(ctx context.Context, releaseID int64, filena
return errors.Wrap(err, "failed to get abs path")
}

f, err := os.Open(filename)
if err != nil {
return errors.Wrap(err, "failed to open file")
}

opts := &github.UploadOptions{
// Use base name by default
Name: filepath.Base(filename),
}

if err := retry.Retry(3, 3*time.Second, func() error {
f, err := os.Open(filename)
if err != nil {
return errors.Wrap(err, "failed to open file")
}
defer f.Close()
if _, _, err = c.Repositories.UploadReleaseAsset(context.TODO(), c.owner, c.repo, releaseID, opts, f); err != nil {
return errors.Wrapf(err, "failed to upload release asset: %s\n", filename)
}
Expand Down

0 comments on commit 861715c

Please # to comment.