Skip to content

Commit fa45c04

Browse files
committed
Added creation of SHA256SUMS file
1 parent 474842b commit fa45c04

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

tools/release/release.go

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
package main
2424

2525
import (
26+
"crypto/sha256"
27+
"encoding/hex"
2628
"flag"
2729
"fmt"
2830
"io/ioutil"
@@ -42,6 +44,12 @@ var (
4244
ghUser string // Github account name to create release in
4345
ghRepo string // Github repository name to create release in
4446
binFolder string // Folder containing binaries
47+
48+
binaries = map[string]string{
49+
"arangodb-darwin-amd64": "darwin/amd64/arangodb",
50+
"arangodb-linux-amd64": "linux/amd64/arangodb",
51+
"arangodb-windows-amd64.exe": "windows/amd64/arangodb.exe",
52+
}
4553
)
4654

4755
func init() {
@@ -60,6 +68,7 @@ func main() {
6068
version := bumpVersion(releaseType)
6169
make("clean")
6270
make("binaries")
71+
createSHA256Sums()
6372
make("docker-push-version")
6473
gitTag(version)
6574
githubCreateRelease(version)
@@ -148,6 +157,23 @@ func gitTag(version string) {
148157
}
149158
}
150159

160+
func createSHA256Sums() {
161+
sums := []string{}
162+
for name, p := range binaries {
163+
blob, err := ioutil.ReadFile(filepath.Join(binFolder, p))
164+
if err != nil {
165+
log.Fatalf("Failed to read binary '%s': %#v\n", name, err)
166+
}
167+
bytes := sha256.Sum256(blob)
168+
sha := hex.EncodeToString(bytes[:])
169+
sums = append(sums, sha+" "+name)
170+
}
171+
sumsPath := filepath.Join(binFolder, "SHA256SUMS")
172+
if err := ioutil.WriteFile(sumsPath, []byte(strings.Join(sums, "\n")+"\n"), 0644); err != nil {
173+
log.Fatalf("Failed to write '%s': %#v\n", sumsPath, err)
174+
}
175+
}
176+
151177
func githubCreateRelease(version string) {
152178
// Create draft release
153179
args := []string{
@@ -162,9 +188,10 @@ func githubCreateRelease(version string) {
162188
}
163189
// Upload binaries
164190
assets := map[string]string{
165-
"arangodb-darwin-amd64": "darwin/amd64/arangodb",
166-
"arangodb-linux-amd64": "linux/amd64/arangodb",
167-
"arangodb-windows-amd64.exe": "windows/amd64/arangodb.exe",
191+
"SHA256SUMS": "SHA256SUMS",
192+
}
193+
for k, v := range binaries {
194+
assets[k] = v
168195
}
169196
for name, file := range assets {
170197
args := []string{

0 commit comments

Comments
 (0)