Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
5da9760a
Commit
5da9760a
authored
Nov 05, 2018
by
Leonard Gram
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
build: publisher supports both local and remote.
parent
d9eaec99
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
27 deletions
+55
-27
scripts/build/release_publisher/externalrelease.go
+3
-2
scripts/build/release_publisher/localrelease.go
+9
-8
scripts/build/release_publisher/main.go
+25
-8
scripts/build/release_publisher/publisher.go
+4
-4
scripts/build/release_publisher/publisher_test.go
+14
-5
No files found.
scripts/build/release_publisher/externalrelease.go
View file @
5da9760a
...
...
@@ -11,15 +11,16 @@ import (
type
releaseFromExternalContent
struct
{
getter
urlGetter
rawVersion
string
artifactConfigurations
[]
buildArtifact
}
func
(
re
releaseFromExternalContent
)
prepareRelease
(
baseArchiveUrl
,
whatsNewUrl
string
,
releaseNotesUrl
string
,
artifactConfigurations
[]
buildArtifact
)
(
*
release
,
error
)
{
func
(
re
releaseFromExternalContent
)
prepareRelease
(
baseArchiveUrl
,
whatsNewUrl
string
,
releaseNotesUrl
string
)
(
*
release
,
error
)
{
version
:=
re
.
rawVersion
[
1
:
]
now
:=
time
.
Now
()
isBeta
:=
strings
.
Contains
(
version
,
"beta"
)
builds
:=
[]
build
{}
for
_
,
ba
:=
range
artifactConfigurations
{
for
_
,
ba
:=
range
re
.
artifactConfigurations
{
sha256
,
err
:=
re
.
getter
.
getContents
(
fmt
.
Sprintf
(
"%s.sha256"
,
ba
.
getUrl
(
baseArchiveUrl
,
version
,
isBeta
)))
if
err
!=
nil
{
return
nil
,
err
...
...
scripts/build/release_publisher/localrelease.go
View file @
5da9760a
...
...
@@ -14,14 +14,16 @@ import (
type
releaseLocalSources
struct
{
path
string
artifactConfigurations
[]
buildArtifact
}
func
(
r
releaseLocalSources
)
prepareRelease
(
baseArchiveUrl
,
whatsNewUrl
string
,
releaseNotesUrl
string
,
artifactConfigurations
[]
buildArtifact
)
(
*
release
,
error
)
{
buildData
:=
r
.
findBuilds
(
artifactConfigurations
,
baseArchiveUrl
)
func
(
r
releaseLocalSources
)
prepareRelease
(
baseArchiveUrl
,
whatsNewUrl
string
,
releaseNotesUrl
string
)
(
*
release
,
error
)
{
buildData
:=
r
.
findBuilds
(
baseArchiveUrl
)
now
:=
time
.
Now
()
rel
:=
release
{
Version
:
buildData
.
version
,
ReleaseDate
:
time
.
Time
{}
,
ReleaseDate
:
time
.
Date
(
now
.
Year
(),
now
.
Month
(),
now
.
Day
(),
0
,
0
,
0
,
0
,
time
.
Local
)
,
Stable
:
false
,
Beta
:
false
,
Nightly
:
true
,
...
...
@@ -38,9 +40,9 @@ type buildData struct {
builds
[]
build
}
func
(
r
releaseLocalSources
)
findBuilds
(
b
uildArtifacts
[]
buildArtifact
,
b
aseArchiveUrl
string
)
buildData
{
func
(
r
releaseLocalSources
)
findBuilds
(
baseArchiveUrl
string
)
buildData
{
data
:=
buildData
{}
filepath
.
Walk
(
r
.
path
,
createBuildWalker
(
r
.
path
,
&
data
,
buildArtifact
s
,
baseArchiveUrl
))
filepath
.
Walk
(
r
.
path
,
createBuildWalker
(
r
.
path
,
&
data
,
r
.
artifactConfiguration
s
,
baseArchiveUrl
))
return
data
}
...
...
@@ -54,14 +56,13 @@ func createBuildWalker(path string, data *buildData, archiveTypes []buildArtifac
return
nil
}
for
_
,
archive
:=
range
archiveTypes
{
if
strings
.
HasSuffix
(
f
.
Name
(),
archive
.
urlPostfix
)
{
shaBytes
,
err
:=
ioutil
.
ReadFile
(
path
+
".sha256"
)
if
err
!=
nil
{
log
.
Fatalf
(
"Failed to read sha256 file %v"
,
err
)
}
for
_
,
archive
:=
range
archiveTypes
{
if
strings
.
HasSuffix
(
f
.
Name
(),
archive
.
urlPostfix
)
{
version
,
err
:=
grabVersion
(
f
.
Name
(),
archive
.
urlPostfix
)
if
err
!=
nil
{
log
.
Println
(
err
)
...
...
scripts/build/release_publisher/main.go
View file @
5da9760a
...
...
@@ -13,6 +13,7 @@ func main() {
var
releaseNotesUrl
string
var
dryRun
bool
var
enterprise
bool
var
fromLocal
bool
var
apiKey
string
flag
.
StringVar
(
&
version
,
"version"
,
""
,
"Grafana version (ex: --version v5.2.0-beta1)"
)
...
...
@@ -21,6 +22,7 @@ func main() {
flag
.
StringVar
(
&
apiKey
,
"apikey"
,
""
,
"Grafana.com API key (ex: --apikey ABCDEF)"
)
flag
.
BoolVar
(
&
dryRun
,
"dry-run"
,
false
,
"--dry-run"
)
flag
.
BoolVar
(
&
enterprise
,
"enterprise"
,
false
,
"--enterprise"
)
flag
.
BoolVar
(
&
fromLocal
,
"from-local"
,
false
,
"--from-local"
)
flag
.
Parse
()
if
len
(
os
.
Args
)
==
1
{
...
...
@@ -33,24 +35,39 @@ func main() {
log
.
Println
(
"Dry-run has been enabled."
)
}
var
baseUrl
string
var
builder
releaseBuilder
var
product
string
if
fromLocal
{
path
,
_
:=
os
.
Getwd
()
builder
=
releaseLocalSources
{
path
:
path
,
artifactConfigurations
:
buildArtifactConfigurations
,
}
}
else
{
builder
=
releaseFromExternalContent
{
getter
:
getHttpContents
{},
rawVersion
:
version
,
artifactConfigurations
:
buildArtifactConfigurations
,
}
}
if
enterprise
{
baseUrl
=
fmt
.
Sprintf
(
"https://s3-us-west-2.amazonaws.com/%s"
,
"grafana-enterprise-releases/release/grafana-enterprise"
)
baseUrl
=
"https://s3-us-west-2.amazonaws.com/grafana-enterprise-releases/release/grafana-enterprise"
product
=
"grafana-enterprise"
}
else
{
baseUrl
=
fmt
.
Sprintf
(
"https://s3-us-west-2.amazonaws.com/%s"
,
"grafana-releases/release/grafana"
)
baseUrl
=
"https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana"
product
=
"grafana"
}
p
:=
publisher
{
apiKey
:
apiKey
,
baseUri
:
"https://grafana.com/api"
,
product
:
"grafana"
,
apiUri
:
"https://grafana.com/api"
,
product
:
product
,
dryRun
:
dryRun
,
enterprise
:
enterprise
,
baseArchiveUrl
:
baseUrl
,
builder
:
releaseFromExternalContent
{
getter
:
getHttpContents
{},
rawVersion
:
version
,
},
builder
:
builder
,
}
if
err
:=
p
.
doRelease
(
whatsNewUrl
,
releaseNotesUrl
);
err
!=
nil
{
log
.
Fatalf
(
"error: %v"
,
err
)
...
...
scripts/build/release_publisher/publisher.go
View file @
5da9760a
...
...
@@ -13,7 +13,7 @@ import (
type
publisher
struct
{
apiKey
string
baseUri
string
apiUri
string
product
string
dryRun
bool
enterprise
bool
...
...
@@ -22,11 +22,11 @@ type publisher struct {
}
type
releaseBuilder
interface
{
prepareRelease
(
baseArchiveUrl
,
whatsNewUrl
string
,
releaseNotesUrl
string
,
artifactConfigurations
[]
buildArtifact
)
(
*
release
,
error
)
prepareRelease
(
baseArchiveUrl
,
whatsNewUrl
string
,
releaseNotesUrl
string
)
(
*
release
,
error
)
}
func
(
p
*
publisher
)
doRelease
(
whatsNewUrl
string
,
releaseNotesUrl
string
)
error
{
currentRelease
,
err
:=
p
.
builder
.
prepareRelease
(
p
.
baseArchiveUrl
,
whatsNewUrl
,
releaseNotesUrl
,
buildArtifactConfigurations
)
currentRelease
,
err
:=
p
.
builder
.
prepareRelease
(
p
.
baseArchiveUrl
,
whatsNewUrl
,
releaseNotesUrl
)
if
err
!=
nil
{
return
err
}
...
...
@@ -151,7 +151,7 @@ func newBuild(baseArchiveUrl string, ba buildArtifact, version string, isBeta bo
}
func
(
p
*
publisher
)
apiUrl
(
url
string
)
string
{
return
fmt
.
Sprintf
(
"%s/%s%s"
,
p
.
base
Uri
,
p
.
product
,
url
)
return
fmt
.
Sprintf
(
"%s/%s%s"
,
p
.
api
Uri
,
p
.
product
,
url
)
}
func
(
p
*
publisher
)
postRequest
(
url
string
,
obj
interface
{},
desc
string
)
error
{
...
...
scripts/build/release_publisher/publisher_test.go
View file @
5da9760a
...
...
@@ -16,9 +16,10 @@ func TestPreparingReleaseFromRemote(t *testing.T) {
builder
=
releaseFromExternalContent
{
getter
:
mockHttpGetter
{},
rawVersion
:
versionIn
,
artifactConfigurations
:
buildArtifactConfigurations
,
}
rel
,
_
:=
builder
.
prepareRelease
(
"https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana"
,
whatsNewUrl
,
relNotesUrl
,
buildArtifacts
)
rel
,
_
:=
builder
.
prepareRelease
(
"https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana"
,
whatsNewUrl
,
relNotesUrl
)
if
!
rel
.
Beta
||
rel
.
Stable
{
t
.
Errorf
(
"%s should have been tagged as beta (not stable), but wasn't ."
,
versionIn
)
...
...
@@ -57,11 +58,13 @@ func TestPreparingReleaseFromLocal(t *testing.T) {
expectedBuilds
:=
4
var
builder
releaseBuilder
testDataPath
:=
"local_test_data"
builder
=
releaseLocalSources
{
path
:
"local_test_data"
,
path
:
testDataPath
,
artifactConfigurations
:
buildArtifactConfigurations
,
}
relAll
,
_
:=
builder
.
prepareRelease
(
"https://s3-us-west-2.amazonaws.com/grafana-enterprise-releases/master/grafana-enterprise"
,
whatsNewUrl
,
relNotesUrl
,
buildArtifactConfigurations
)
relAll
,
_
:=
builder
.
prepareRelease
(
"https://s3-us-west-2.amazonaws.com/grafana-enterprise-releases/master/grafana-enterprise"
,
whatsNewUrl
,
relNotesUrl
)
if
relAll
.
Stable
||
!
relAll
.
Nightly
{
t
.
Error
(
"Expected a nightly release but wasn't."
)
...
...
@@ -88,11 +91,17 @@ func TestPreparingReleaseFromLocal(t *testing.T) {
expectedArch
:=
"amd64"
expectedOs
:=
"win"
relOne
,
_
:=
builder
.
prepareRelease
(
"https://s3-us-west-2.amazonaws.com/grafana-enterprise-releases/master/grafana-enterprise"
,
whatsNewUrl
,
relNotesUrl
,
[]
buildArtifact
{{
builder
=
releaseLocalSources
{
path
:
testDataPath
,
artifactConfigurations
:
[]
buildArtifact
{{
os
:
expectedOs
,
arch
:
expectedArch
,
urlPostfix
:
".windows-amd64.zip"
,
}})
}},
}
relOne
,
_
:=
builder
.
prepareRelease
(
"https://s3-us-west-2.amazonaws.com/grafana-enterprise-releases/master/grafana-enterprise"
,
whatsNewUrl
,
relNotesUrl
)
if
len
(
relOne
.
Builds
)
!=
1
{
t
.
Errorf
(
"Expected 1 artifact, but was %v"
,
len
(
relOne
.
Builds
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment