Move releasing binaries to a more general function and add ones of linux + darwin

This commit is contained in:
kolaente 2020-09-02 18:11:45 +02:00
parent 33d410946a
commit b074a6bd61
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 19 additions and 18 deletions

View File

@ -27,6 +27,7 @@ import (
"io"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
)
@ -151,7 +152,7 @@ func init() {
setApiPackages()
setRootPath()
setGoFiles()
Ldflags = `-X "` + PACKAGE + `/pkg/version.VersionNumber=` + VersionNumber + `" -X "main.Tags=` + Tags + `"`
Ldflags = `-X "` + PACKAGE + `/pkg/version.Version=` + VersionNumber + `" -X "main.Tags=` + Tags + `"`
}
func runAndStreamOutput(cmd string, args ...string) {
@ -401,34 +402,34 @@ func (Release) Dirs() error {
return nil
}
// Builds binaries for windows
func (Release) Windows() {
func runXgo(targets string) error {
checkAndInstallGoTool("xgo", "src.techknowlogick.com/xgo")
runAndStreamOutput("xgo",
"-dest", RootPath+"/"+DIST+"/binaries",
"-tags", "'netgo "+Tags+"'",
"-ldflags", "'-linkmode external -extldflags \"-static\" "+Ldflags+"'",
"-targets", "'windows/*'",
"-tags", "netgo "+Tags,
"-ldflags", `-linkmode external -extldflags "-static" `+Ldflags,
"-targets", targets,
"-out", Executable+"-"+Version,
".")
RootPath)
if os.Getenv("DRONE_WORKSPACE") != "" {
//os.Rename("/build/")
return filepath.Walk("/build/", func(path string, info os.FileInfo, err error) error {
return os.Rename(path, RootPath+"/"+DIST+"/"+info.Name())
})
}
/*
xgo -dest $(DIST)/binaries -tags 'netgo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out vikunja-$(VERSION) .
ifneq ($(DRONE_WORKSPACE),'')
mv /build/* $(DIST)/binaries
endif
*/
return nil
}
func (Release) Linux() {
// Builds binaries for windows
func (Release) Windows() error {
return runXgo("windows/*")
}
func (Release) Darwin() {
func (Release) Linux() error {
return runXgo("linux/*")
}
func (Release) Darwin() error {
return runXgo("darwin/*")
}
func (Release) Compress() {