Fix nfpm command in drone

This commit is contained in:
kolaente 2020-10-19 07:58:24 +02:00
parent 47486af06d
commit 004e432e7c
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -652,7 +652,14 @@ func (Release) Reprepro() {
// Creates deb, rpm and apk packages // Creates deb, rpm and apk packages
func (Release) Packages() error { func (Release) Packages() error {
mg.Deps(initVars) mg.Deps(initVars)
if err := exec.Command("nfpm").Run(); err != nil && strings.Contains(err.Error(), "executable file not found") { var err error
binpath := "nfpm"
err = exec.Command(binpath).Run()
if err != nil && strings.Contains(err.Error(), "executable file not found") {
binpath = "/nfpm"
err = exec.Command(binpath).Run()
}
if err != nil && strings.Contains(err.Error(), "executable file not found") {
fmt.Println("Please manually install nfpm by running") fmt.Println("Please manually install nfpm by running")
fmt.Println("curl -sfL https://install.goreleaser.com/github.com/goreleaser/nfpm.sh | sh -s -- -b $(go env GOPATH)/bin") fmt.Println("curl -sfL https://install.goreleaser.com/github.com/goreleaser/nfpm.sh | sh -s -- -b $(go env GOPATH)/bin")
os.Exit(1) os.Exit(1)
@ -676,9 +683,9 @@ func (Release) Packages() error {
return err return err
} }
runAndStreamOutput("nfpm", "pkg", "--packager", "deb", "--target", releasePath) runAndStreamOutput(binpath, "pkg", "--packager", "deb", "--target", releasePath)
runAndStreamOutput("nfpm", "pkg", "--packager", "rpm", "--target", releasePath) runAndStreamOutput(binpath, "pkg", "--packager", "rpm", "--target", releasePath)
runAndStreamOutput("nfpm", "pkg", "--packager", "apk", "--target", releasePath) runAndStreamOutput(binpath, "pkg", "--packager", "apk", "--target", releasePath)
return ioutil.WriteFile(nfpmConfigPath, nfpmconfig, 0) return ioutil.WriteFile(nfpmConfigPath, nfpmconfig, 0)
} }