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
import (
"crypto/sha256"
"encoding/hex"
"encoding/json"
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"os"
@ -202,12 +205,14 @@ func unixInstaller(textfiles []string, buildos, buildarch, dir string, buildMatr
}
name := zipName(buildos, buildarch) + ".tar.gz"
addToMatrix(buildMatrix, buildos, buildarch, name)
cmd = exec.Command("tar", "czf", "../"+name, filepath.Base(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 {
@ -232,24 +237,47 @@ func winInstaller(textfiles []string, buildos, buildarch, dir string, buildMatri
return err
}
addToMatrix(buildMatrix, buildos, buildarch, name)
args := make([]string, len(matches)+2)
args[0] = "-j" // junk the zip paths
args[1] = full
copy(args[2:], matches)
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) {
buildMatrix[fmt.Sprintf("%s-%s", buildos, buildarch)] = Release{
Label: releaseLabel(buildos, buildarch),
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 {
fmt.Printf(" - %s\n", strings.Join(cmd.Args, " "))
if len(cmd.Dir) > 0 {

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

@ -39,6 +39,11 @@ func mainRelease() {
release(rel)
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) {

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