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:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user