CI: Generate Grafana version (and metadata) when the build binary is built (#54393)

* Add GenerateVersions as BeforeFunc

* Delete gen-version

* Fix lint

* Get build id from env var
This commit is contained in:
Dimitris Sotirakis
2022-09-01 15:43:40 +03:00
committed by GitHub
parent 4ec03bad64
commit 7e2238cf6f
13 changed files with 128 additions and 194 deletions
+9
View File
@@ -16,6 +16,7 @@ type Metadata struct {
GrafanaVersion string `json:"version,omitempty"`
ReleaseMode ReleaseMode `json:"releaseMode,omitempty"`
GrabplVersion string `json:"grabplVersion,omitempty"`
CurrentCommit string `json:"currentCommit,omitempty"`
}
type ReleaseMode struct {
@@ -170,3 +171,11 @@ func CheckSemverSuffix() (ReleaseMode, error) {
return ReleaseMode{Mode: TagMode}, nil
}
}
func GetDroneCommit() (string, error) {
commit := strings.TrimSpace(os.Getenv("DRONE_COMMIT"))
if commit == "" {
return "", fmt.Errorf("the environment variable DRONE_COMMIT is missing")
}
return commit, nil
}
+12
View File
@@ -10,3 +10,15 @@ const (
PullRequestMode VersionMode = "pull_request"
CustomMode VersionMode = "custom"
)
const (
Tag = "tag"
PullRequest = "pull_request"
Push = "push"
Custom = "custom"
Promote = "promote"
)
const (
MainBranch = "main"
)