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
7e093a32
Commit
7e093a32
authored
Oct 31, 2018
by
Leonard Gram
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
build: improved release publisher dry-run.
parent
a1dca211
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
28 deletions
+29
-28
scripts/build/release_publisher/main.go
+7
-4
scripts/build/release_publisher/publisher.go
+22
-24
No files found.
scripts/build/release_publisher/main.go
View file @
7e093a32
...
@@ -7,8 +7,6 @@ import (
...
@@ -7,8 +7,6 @@ import (
"os"
"os"
)
)
var
baseUri
string
=
"https://grafana.com/api"
func
main
()
{
func
main
()
{
var
version
string
var
version
string
var
whatsNewUrl
string
var
whatsNewUrl
string
...
@@ -33,8 +31,13 @@ func main() {
...
@@ -33,8 +31,13 @@ func main() {
log
.
Println
(
"Dry-run has been enabled."
)
log
.
Println
(
"Dry-run has been enabled."
)
}
}
p
:=
publisher
{
apiKey
:
apiKey
}
p
:=
publisher
{
if
err
:=
p
.
doRelease
(
version
,
whatsNewUrl
,
releaseNotesUrl
,
dryRun
);
err
!=
nil
{
apiKey
:
apiKey
,
baseUri
:
"https://grafana.com/api"
,
product
:
"grafana"
,
dryRun
:
dryRun
,
}
if
err
:=
p
.
doRelease
(
version
,
whatsNewUrl
,
releaseNotesUrl
);
err
!=
nil
{
log
.
Fatalf
(
"error: %v"
,
err
)
log
.
Fatalf
(
"error: %v"
,
err
)
}
}
}
}
scripts/build/release_publisher/publisher.go
View file @
7e093a32
...
@@ -13,52 +13,39 @@ import (
...
@@ -13,52 +13,39 @@ import (
type
publisher
struct
{
type
publisher
struct
{
apiKey
string
apiKey
string
baseUri
string
product
string
dryRun
bool
}
}
func
(
p
*
publisher
)
doRelease
(
version
string
,
whatsNewUrl
string
,
releaseNotesUrl
string
,
dryRun
bool
)
error
{
func
(
p
*
publisher
)
doRelease
(
version
string
,
whatsNewUrl
string
,
releaseNotesUrl
string
)
error
{
currentRelease
,
err
:=
newRelease
(
version
,
whatsNewUrl
,
releaseNotesUrl
,
buildArtifactConfigurations
,
getHttpContents
{})
currentRelease
,
err
:=
newRelease
(
version
,
whatsNewUrl
,
releaseNotesUrl
,
buildArtifactConfigurations
,
getHttpContents
{})
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
if
dryRun
{
if
err
:=
p
.
postRelease
(
currentRelease
);
err
!=
nil
{
relJson
,
err
:=
json
.
Marshal
(
currentRelease
)
return
err
if
err
!=
nil
{
return
err
}
log
.
Println
(
string
(
relJson
))
for
_
,
b
:=
range
currentRelease
.
Builds
{
artifactJson
,
err
:=
json
.
Marshal
(
b
)
if
err
!=
nil
{
return
err
}
log
.
Println
(
string
(
artifactJson
))
}
}
else
{
if
err
:=
p
.
postRelease
(
currentRelease
);
err
!=
nil
{
return
err
}
}
}
return
nil
return
nil
}
}
func
(
p
*
publisher
)
postRelease
(
r
*
release
)
error
{
func
(
p
*
publisher
)
postRelease
(
r
*
release
)
error
{
err
:=
p
.
postRequest
(
"/
grafana/
versions"
,
r
,
fmt
.
Sprintf
(
"Create Release %s"
,
r
.
Version
))
err
:=
p
.
postRequest
(
"/versions"
,
r
,
fmt
.
Sprintf
(
"Create Release %s"
,
r
.
Version
))
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
err
=
p
.
postRequest
(
"/
grafana/
versions/"
+
r
.
Version
,
r
,
fmt
.
Sprintf
(
"Update Release %s"
,
r
.
Version
))
err
=
p
.
postRequest
(
"/versions/"
+
r
.
Version
,
r
,
fmt
.
Sprintf
(
"Update Release %s"
,
r
.
Version
))
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
for
_
,
b
:=
range
r
.
Builds
{
for
_
,
b
:=
range
r
.
Builds
{
err
=
p
.
postRequest
(
fmt
.
Sprintf
(
"/
grafana/
versions/%s/packages"
,
r
.
Version
),
b
,
fmt
.
Sprintf
(
"Create Build %s %s"
,
b
.
Os
,
b
.
Arch
))
err
=
p
.
postRequest
(
fmt
.
Sprintf
(
"/versions/%s/packages"
,
r
.
Version
),
b
,
fmt
.
Sprintf
(
"Create Build %s %s"
,
b
.
Os
,
b
.
Arch
))
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
err
=
p
.
postRequest
(
fmt
.
Sprintf
(
"/
grafana/
versions/%s/packages/%s/%s"
,
r
.
Version
,
b
.
Arch
,
b
.
Os
),
b
,
fmt
.
Sprintf
(
"Update Build %s %s"
,
b
.
Os
,
b
.
Arch
))
err
=
p
.
postRequest
(
fmt
.
Sprintf
(
"/versions/%s/packages/%s/%s"
,
r
.
Version
,
b
.
Arch
,
b
.
Os
),
b
,
fmt
.
Sprintf
(
"Update Build %s %s"
,
b
.
Os
,
b
.
Arch
))
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -185,12 +172,23 @@ func newBuild(ba buildArtifact, version string, isBeta bool, sha256 string) buil
...
@@ -185,12 +172,23 @@ func newBuild(ba buildArtifact, version string, isBeta bool, sha256 string) buil
}
}
}
}
func
(
p
*
publisher
)
apiUrl
(
url
string
)
string
{
return
fmt
.
Sprintf
(
"%s/%s%s"
,
p
.
baseUri
,
p
.
product
,
url
)
}
func
(
p
*
publisher
)
postRequest
(
url
string
,
obj
interface
{},
desc
string
)
error
{
func
(
p
*
publisher
)
postRequest
(
url
string
,
obj
interface
{},
desc
string
)
error
{
jsonBytes
,
err
:=
json
.
Marshal
(
obj
)
jsonBytes
,
err
:=
json
.
Marshal
(
obj
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
req
,
err
:=
http
.
NewRequest
(
http
.
MethodPost
,
baseUri
+
url
,
bytes
.
NewReader
(
jsonBytes
))
if
p
.
dryRun
{
log
.
Println
(
fmt
.
Sprintf
(
"POST to %s:"
,
p
.
apiUrl
(
url
)))
log
.
Println
(
string
(
jsonBytes
))
return
nil
}
req
,
err
:=
http
.
NewRequest
(
http
.
MethodPost
,
p
.
apiUrl
(
url
),
bytes
.
NewReader
(
jsonBytes
))
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
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