Merge pull request #1687 from git-lfs/release-fixes

Release fixes
This commit is contained in:
risk danger olson 2016-11-18 11:57:21 -09:00 committed by GitHub
commit 4cf27ebd29
4 changed files with 42 additions and 7 deletions

@ -1,9 +1,12 @@
package main package main
import ( import (
"crypto/sha256"
"encoding/hex"
"encoding/json" "encoding/json"
"flag" "flag"
"fmt" "fmt"
"io"
"io/ioutil" "io/ioutil"
"log" "log"
"os" "os"
@ -202,12 +205,14 @@ func unixInstaller(textfiles []string, buildos, buildarch, dir string, buildMatr
} }
name := zipName(buildos, buildarch) + ".tar.gz" name := zipName(buildos, buildarch) + ".tar.gz"
addToMatrix(buildMatrix, buildos, buildarch, name)
cmd = exec.Command("tar", "czf", "../"+name, filepath.Base(dir)) cmd = exec.Command("tar", "czf", "../"+name, filepath.Base(dir))
cmd.Dir = filepath.Dir(dir) cmd.Dir = filepath.Dir(dir)
return logAndRun(cmd) if err := logAndRun(cmd); err != nil {
return nil
}
addToMatrix(buildMatrix, buildos, buildarch, name)
return nil
} }
func winInstaller(textfiles []string, buildos, buildarch, dir string, buildMatrix map[string]Release) error { func winInstaller(textfiles []string, buildos, buildarch, dir string, buildMatrix map[string]Release) error {
@ -232,24 +237,47 @@ func winInstaller(textfiles []string, buildos, buildarch, dir string, buildMatri
return err return err
} }
addToMatrix(buildMatrix, buildos, buildarch, name)
args := make([]string, len(matches)+2) args := make([]string, len(matches)+2)
args[0] = "-j" // junk the zip paths args[0] = "-j" // junk the zip paths
args[1] = full args[1] = full
copy(args[2:], matches) copy(args[2:], matches)
cmd := exec.Command("zip", args...) cmd := exec.Command("zip", args...)
return logAndRun(cmd) if err := logAndRun(cmd); err != nil {
return err
}
addToMatrix(buildMatrix, buildos, buildarch, name)
return nil
} }
func addToMatrix(buildMatrix map[string]Release, buildos, buildarch, name string) { func addToMatrix(buildMatrix map[string]Release, buildos, buildarch, name string) {
buildMatrix[fmt.Sprintf("%s-%s", buildos, buildarch)] = Release{ buildMatrix[fmt.Sprintf("%s-%s", buildos, buildarch)] = Release{
Label: releaseLabel(buildos, buildarch), Label: releaseLabel(buildos, buildarch),
Filename: name, Filename: name,
SHA256: hashRelease(name),
} }
} }
func hashRelease(name string) string {
full := filepath.Join("bin/releases", name)
file, err := os.Open(full)
if err != nil {
fmt.Printf("unable to open release %q: %+v\n", full, err)
os.Exit(1)
}
defer file.Close()
h := sha256.New()
if _, err = io.Copy(h, file); err != nil {
fmt.Printf("error reading release %q: %+v\n", full, err)
os.Exit(1)
}
return hex.EncodeToString(h.Sum(nil))
}
func logAndRun(cmd *exec.Cmd) error { func logAndRun(cmd *exec.Cmd) error {
fmt.Printf(" - %s\n", strings.Join(cmd.Args, " ")) fmt.Printf(" - %s\n", strings.Join(cmd.Args, " "))
if len(cmd.Dir) > 0 { if len(cmd.Dir) > 0 {

@ -35,6 +35,7 @@ $distro_name_map = {
el/7 el/7
fedora/22 fedora/22
fedora/23 fedora/23
fedora/24
), ),
"debian/7" => %w( "debian/7" => %w(
debian/wheezy debian/wheezy

@ -39,6 +39,11 @@ func mainRelease() {
release(rel) release(rel)
fmt.Println() fmt.Println()
} }
fmt.Println("SHA-256 hashes:")
for _, rel := range buildMatrix {
fmt.Printf("**%s**\n%s\n\n", rel.Filename, rel.SHA256)
}
} }
func release(rel Release) { func release(rel Release) {

@ -8,6 +8,7 @@ import (
type Release struct { type Release struct {
Label string Label string
Filename string Filename string
SHA256 string
} }
var SubCommand = flag.String("cmd", "", "Command: build or release") var SubCommand = flag.String("cmd", "", "Command: build or release")