mirror of
https://github.com/grafana/grafana.git
synced 2026-07-29 15:59:50 -05:00
build: releaser supports releasing only some artifacts.
This commit is contained in:
@@ -359,6 +359,9 @@ jobs:
|
|||||||
- run:
|
- run:
|
||||||
name: deploy to gcp
|
name: deploy to gcp
|
||||||
command: '/opt/google-cloud-sdk/bin/gsutil cp ./enterprise-dist/* gs://$GCP_BUCKET_NAME/enterprise/release'
|
command: '/opt/google-cloud-sdk/bin/gsutil cp ./enterprise-dist/* gs://$GCP_BUCKET_NAME/enterprise/release'
|
||||||
|
- run:
|
||||||
|
name: Deploy to Grafana.com
|
||||||
|
command: './scripts/build/publish.sh --enterprise'
|
||||||
|
|
||||||
deploy-master:
|
deploy-master:
|
||||||
docker:
|
docker:
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
# no relation to publish.go
|
# no relation to publish.go
|
||||||
|
|
||||||
|
EXTRA_OPTS="$@"
|
||||||
|
|
||||||
# Right now we hack this in into the publish script.
|
# Right now we hack this in into the publish script.
|
||||||
# Eventually we might want to keep a list of all previous releases somewhere.
|
# Eventually we might want to keep a list of all previous releases somewhere.
|
||||||
_releaseNoteUrl="https://community.grafana.com/t/release-notes-v5-3-x/10244"
|
_releaseNoteUrl="https://community.grafana.com/t/release-notes-v5-3-x/10244"
|
||||||
@@ -11,4 +13,4 @@ _whatsNewUrl="http://docs.grafana.org/guides/whats-new-in-v5-3/"
|
|||||||
--wn ${_whatsNewUrl} \
|
--wn ${_whatsNewUrl} \
|
||||||
--rn ${_releaseNoteUrl} \
|
--rn ${_releaseNoteUrl} \
|
||||||
--version ${CIRCLE_TAG} \
|
--version ${CIRCLE_TAG} \
|
||||||
--apikey ${GRAFANA_COM_API_KEY}
|
--apikey ${GRAFANA_COM_API_KEY} ${EXTRA_OPTS}
|
||||||
|
|||||||
@@ -41,30 +41,43 @@ func main() {
|
|||||||
var builder releaseBuilder
|
var builder releaseBuilder
|
||||||
var product string
|
var product string
|
||||||
|
|
||||||
|
archiveProviderRoot := "https://s3-us-west-2.amazonaws.com"
|
||||||
|
buildArtifacts := completeBuildArtifactConfigurations
|
||||||
|
|
||||||
|
if enterprise {
|
||||||
|
product = "grafana-enterprise"
|
||||||
|
baseUrl = createBaseUrl(archiveProviderRoot, "grafana-enterprise-releases", product, nightly)
|
||||||
|
var err error
|
||||||
|
buildArtifacts, err = filterBuildArtifacts([]artifactFilter{
|
||||||
|
{os: "deb", arch: "amd64"},
|
||||||
|
{os: "rpm", arch: "amd64"},
|
||||||
|
{os: "linux", arch: "amd64"},
|
||||||
|
{os: "windows", arch: "amd64"},
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Could not filter to the selected build artifacts, err=%v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
product = "grafana"
|
||||||
|
baseUrl = createBaseUrl(archiveProviderRoot, "grafana-releases", product, nightly)
|
||||||
|
}
|
||||||
|
|
||||||
if fromLocal {
|
if fromLocal {
|
||||||
path, _ := os.Getwd()
|
path, _ := os.Getwd()
|
||||||
builder = releaseLocalSources{
|
builder = releaseLocalSources{
|
||||||
path: path,
|
path: path,
|
||||||
artifactConfigurations: buildArtifactConfigurations,
|
artifactConfigurations: buildArtifacts,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
builder = releaseFromExternalContent{
|
builder = releaseFromExternalContent{
|
||||||
getter: getHttpContents{},
|
getter: getHttpContents{},
|
||||||
rawVersion: version,
|
rawVersion: version,
|
||||||
artifactConfigurations: buildArtifactConfigurations,
|
artifactConfigurations: buildArtifacts,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
archiveProviderRoot := "https://s3-us-west-2.amazonaws.com"
|
|
||||||
|
|
||||||
if enterprise {
|
|
||||||
product = "grafana-enterprise"
|
|
||||||
baseUrl = createBaseUrl(archiveProviderRoot, "grafana-enterprise-releases", product, nightly)
|
|
||||||
} else {
|
|
||||||
product = "grafana"
|
|
||||||
baseUrl = createBaseUrl(archiveProviderRoot, "grafana-releases", product, nightly)
|
|
||||||
}
|
|
||||||
|
|
||||||
p := publisher{
|
p := publisher{
|
||||||
apiKey: apiKey,
|
apiKey: apiKey,
|
||||||
apiUri: "https://grafana.com/api",
|
apiUri: "https://grafana.com/api",
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/pkg/errors"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -103,7 +104,7 @@ func (t buildArtifact) getUrl(baseArchiveUrl, version string, releaseType Releas
|
|||||||
return url
|
return url
|
||||||
}
|
}
|
||||||
|
|
||||||
var buildArtifactConfigurations = []buildArtifact{
|
var completeBuildArtifactConfigurations = []buildArtifact{
|
||||||
{
|
{
|
||||||
os: "deb",
|
os: "deb",
|
||||||
arch: "arm64",
|
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 {
|
func newBuild(baseArchiveUrl string, ba buildArtifact, version string, rt ReleaseType, sha256 string) build {
|
||||||
return build{
|
return build{
|
||||||
Os: ba.os,
|
Os: ba.os,
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ func TestPreparingReleaseFromLocal(t *testing.T) {
|
|||||||
testDataPath := "testdata"
|
testDataPath := "testdata"
|
||||||
builder = releaseLocalSources{
|
builder = releaseLocalSources{
|
||||||
path: testDataPath,
|
path: testDataPath,
|
||||||
artifactConfigurations: buildArtifactConfigurations,
|
artifactConfigurations: completeBuildArtifactConfigurations,
|
||||||
}
|
}
|
||||||
|
|
||||||
relAll, _ := builder.prepareRelease("https://s3-us-west-2.amazonaws.com/grafana-enterprise-releases/master/grafana-enterprise", whatsNewUrl, relNotesUrl, true)
|
relAll, _ := builder.prepareRelease("https://s3-us-west-2.amazonaws.com/grafana-enterprise-releases/master/grafana-enterprise", whatsNewUrl, relNotesUrl, true)
|
||||||
@@ -176,3 +176,27 @@ func TestPreparingReleaseFromLocal(t *testing.T) {
|
|||||||
t.Error("Error was nil, but expected an error as the local releaser only supports nightly builds.")
|
t.Error("Error was nil, but expected an error as the local releaser only supports nightly builds.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestFilterBuildArtifacts(t *testing.T) {
|
||||||
|
buildArtifacts, _ := filterBuildArtifacts([]artifactFilter{
|
||||||
|
{os: "deb", arch: "amd64"},
|
||||||
|
{os: "rhel", arch: "amd64"},
|
||||||
|
{os: "linux", arch: "amd64"},
|
||||||
|
{os: "win", arch: "amd64"},
|
||||||
|
})
|
||||||
|
|
||||||
|
if len(buildArtifacts) != 4 {
|
||||||
|
t.Errorf("Expected 4 build artifacts after filtering, but was %v", len(buildArtifacts))
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := filterBuildArtifacts([]artifactFilter{
|
||||||
|
{os: "foobar", arch: "amd64"},
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
t.Errorf("Expected an error as a we tried to filter on a nonexiststant os.")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user