1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-02-03 13:11:48 +02:00
This commit is contained in:
Carlos Alexandro Becker 2016-12-21 14:42:23 -02:00
parent efff5d5e17
commit d8bb50f799
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
4 changed files with 17 additions and 20 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
dist
releasr

View File

@ -3,32 +3,29 @@ package build
import (
"bytes"
"fmt"
"os"
"os/exec"
"github.com/goreleaser/releaser/config"
"github.com/kardianos/osext"
)
func Build(version string, config config.ProjectConfig) error {
currentPath, err := osext.ExecutableFolder()
if err != nil {
return err
}
fmt.Println(currentPath)
for _, os := range config.Build.Oses {
for _, bos := range config.Build.Oses {
for _, arch := range config.Build.Arches {
fmt.Println("Building", os, arch)
fmt.Println("Building", bos+"/"+arch+"...")
cmd := exec.Command(
"go", "build",
"-ldflags=\"-s -w -X main.version="+version+"\"",
"-o", target(os, arch, config.BinaryName),
"go",
"build",
"-ldflags=-s -w -X main.version="+version,
"-o", target(bos, arch, config.BinaryName),
config.Main,
)
cmd.Env = append(
cmd.Env,
"GOOS="+os,
"GOOS="+bos,
"GOARCH="+arch,
// "GOPATH="+
"GOROOT="+os.Getenv("GOROOT"),
"GOPATH="+os.Getenv("GOPATH"),
)
var stdout bytes.Buffer
cmd.Stdout = &stdout

View File

@ -2,7 +2,6 @@ package config
import (
"io/ioutil"
"log"
"os"
"path/filepath"
@ -32,7 +31,6 @@ type ProjectConfig struct {
}
func Load(file string) (config ProjectConfig, err error) {
log.Println("Loading", file)
data, err := ioutil.ReadFile(file)
if err != nil {
return config, err
@ -75,12 +73,11 @@ func fix(config ProjectConfig) ProjectConfig {
return config
}
func contains(s string, ss []string) (ok bool) {
func contains(s string, ss []string) bool {
for _, sx := range ss {
if sx == s {
ok = true
break
return true
}
}
return ok
return false
}

View File

@ -7,12 +7,13 @@ import (
"github.com/goreleaser/releaser/config"
)
var version = "none"
func main() {
config, err := config.Load("goreleaser.yml")
if err != nil {
panic(err)
}
fmt.Println(config)
err = build.Build("master", config)
fmt.Println(err)
}