build: releaser supports releasing only some artifacts.

This commit is contained in:
Leonard Gram
2018-11-19 16:55:30 +01:00
parent 87707c964c
commit 84832cb6cb
5 changed files with 83 additions and 15 deletions

View File

@ -4,6 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/pkg/errors"
"io/ioutil"
"log"
"net/http"
@ -103,7 +104,7 @@ func (t buildArtifact) getUrl(baseArchiveUrl, version string, releaseType Releas
return url
}
var buildArtifactConfigurations = []buildArtifact{
var completeBuildArtifactConfigurations = []buildArtifact{
{
os: "deb",
arch: "arm64",
@ -161,6 +162,31 @@ var buildArtifactConfigurations = []buildArtifact{
},
}
type artifactFilter struct {
os string
arch string
}
func filterBuildArtifacts(filters []artifactFilter) ([]buildArtifact, error) {
var artifacts []buildArtifact
for _, f := range filters {
matched := false
for _, a := range completeBuildArtifactConfigurations {
if f.os == a.os && f.arch == a.arch {
artifacts = append(artifacts, a)
matched = true
break
}
}
if !matched {
return nil, errors.New(fmt.Sprintf("No buildArtifact for os=%v, arch=%v", f.os, f.arch))
}
}
return artifacts, nil
}
func newBuild(baseArchiveUrl string, ba buildArtifact, version string, rt ReleaseType, sha256 string) build {
return build{
Os: ba.os,