Skip to content

Commit

Permalink
Fix shasum (#42)
Browse files Browse the repository at this point in the history
* Test better shasum

* Fix sha file basename

* Try hex encoding

* Add newline

* Changelog
  • Loading branch information
Rick Ducott authored Mar 4, 2019
1 parent 36028da commit 2c5125a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions changelog/v0.2.11/fix-sha-to-match-shasum.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
changelog:
- type: FIX
description: Fixes the sha upload in `UploadReleaseAssetsCli` to upload a checksum for `foo` that matches the output of `shasum -a 256 foo > foo.sha256`.
issueLink: https://github.com/solo-io/go-utils/issues/41
5 changes: 3 additions & 2 deletions githubutils/upload_release_asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package githubutils
import (
"context"
"crypto/sha256"
"encoding/hex"
"github.com/google/go-github/github"
"github.com/solo-io/go-utils/contextutils"
"github.com/solo-io/go-utils/versionutils"
Expand Down Expand Up @@ -84,8 +85,8 @@ func writeSha256OrExit(ctx context.Context, file *os.File, outputPath string) {
if _, err := io.Copy(h, file); err != nil {
contextutils.LoggerFrom(ctx).Fatal(err)
}
sha256 := h.Sum(nil)
err := ioutil.WriteFile(outputPath, sha256, 0700)
sha256String := hex.EncodeToString(h.Sum(nil)) + " " + filepath.Base(file.Name()) + "\n"
err := ioutil.WriteFile(outputPath, []byte(sha256String), 0700)
if err != nil {
contextutils.LoggerFrom(ctx).Fatal(err)
}
Expand Down

0 comments on commit 2c5125a

Please sign in to comment.