Skip to content

Commit a86a157

Browse files
committed
cmd/release: supply SHA256 hash when uploading releases
Fixes golang/go#12057 Change-Id: Id66b1ec37a3d2dfb36aac6b70d8b70e537d4f3cb Reviewed-on: https://go-review.googlesource.com/18353 Reviewed-by: Russ Cox <rsc@golang.org>
1 parent 2c7c419 commit a86a157

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

cmd/release/upload.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package main
66

77
import (
88
"bytes"
9-
"crypto/sha1"
9+
"crypto/sha256"
1010
"encoding/json"
1111
"fmt"
1212
"io/ioutil"
@@ -31,15 +31,15 @@ const (
3131
)
3232

3333
// File represents a file on the golang.org downloads page.
34-
// It should be kept in sync with the (currently Google-interal) download code.
34+
// It should be kept in sync with the download code in x/tools/godoc/dl.
3535
type File struct {
36-
Filename string
37-
OS string
38-
Arch string
39-
Version string
40-
Checksum string
41-
Size int64
42-
Kind string // "archive", "installer", "source"
36+
Filename string
37+
OS string
38+
Arch string
39+
Version string
40+
ChecksumSHA256 string
41+
Size int64
42+
Kind string // "archive", "installer", "source"
4343
}
4444

4545
// fileRe matches the files created by the release tool, such as:
@@ -106,13 +106,13 @@ func uploadFile(ctx context.Context, c *storage.Client, b *Build, version, filen
106106
kind = "installer"
107107
}
108108
req, err := json.Marshal(File{
109-
Filename: base,
110-
Version: version,
111-
OS: b.OS,
112-
Arch: b.Arch,
113-
Checksum: fmt.Sprintf("%x", sha1.Sum(file)),
114-
Size: int64(len(file)),
115-
Kind: kind,
109+
Filename: base,
110+
Version: version,
111+
OS: b.OS,
112+
Arch: b.Arch,
113+
ChecksumSHA256: fmt.Sprintf("%x", sha256.Sum256(file)),
114+
Size: int64(len(file)),
115+
Kind: kind,
116116
})
117117
if err != nil {
118118
return err

0 commit comments

Comments
 (0)