mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Grafana Build: Sync Grafana versioning changes from build-pipeline (#53522)
* Sync version changes (cherry picked from commit fb449ba0376cd7d86928e8b08ef77a851488604b) Sync version refactoring changes * Update grabpl
This commit is contained in:
committed by
GitHub
parent
6423485061
commit
fa4abdcce1
@@ -14,10 +14,16 @@ import (
|
||||
|
||||
type Metadata struct {
|
||||
GrafanaVersion string `json:"version,omitempty"`
|
||||
ReleaseMode VersionMode `json:"releaseMode,omitempty"`
|
||||
ReleaseMode ReleaseMode `json:"releaseMode,omitempty"`
|
||||
GrabplVersion string `json:"grabplVersion,omitempty"`
|
||||
}
|
||||
|
||||
type ReleaseMode struct {
|
||||
Mode VersionMode `json:"mode,omitempty"`
|
||||
IsBeta bool `json:"isBeta,omitempty"`
|
||||
IsTest bool `json:"isTest,omitempty"`
|
||||
}
|
||||
|
||||
type PluginSignature struct {
|
||||
Sign bool `json:"sign,omitempty"`
|
||||
AdminSign bool `json:"adminSign,omitempty"`
|
||||
@@ -41,13 +47,17 @@ type Version struct {
|
||||
StorybookSrcDir string `json:"storybookSrcDir,omitempty"`
|
||||
}
|
||||
|
||||
func (md *Metadata) GetReleaseMode() (ReleaseMode, error) {
|
||||
return md.ReleaseMode, nil
|
||||
}
|
||||
|
||||
// Versions is a map of versions. Each key of the Versions map is an event that uses the the config as the value for that key.
|
||||
// For example, the 'pull_request' key will have data in it that might cause Grafana to be built differently in a pull request,
|
||||
// than the way it will be built in 'main'
|
||||
type VersionMap map[VersionMode]Version
|
||||
|
||||
// GetMetadata attempts to read the JSON file located at 'path' and decode it as a Metadata{} type.
|
||||
// If the provided path deos not exist, then an error is not returned. Instead, an empty metadata is returned with no error.
|
||||
// If the provided path does not exist, then an error is not returned. Instead, an empty metadata is returned with no error.
|
||||
func GetMetadata(path string) (*Metadata, error) {
|
||||
if _, err := os.Stat(path); err != nil {
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
@@ -142,21 +152,21 @@ func CheckDroneTargetBranch() (VersionMode, error) {
|
||||
return "", fmt.Errorf("unrecognized target branch: %s", target)
|
||||
}
|
||||
|
||||
func CheckSemverSuffix() (VersionMode, error) {
|
||||
func CheckSemverSuffix() (ReleaseMode, error) {
|
||||
reBetaRls := regexp.MustCompile(`beta.*`)
|
||||
reTestRls := regexp.MustCompile(`test.*`)
|
||||
tagSuffix, ok := os.LookupEnv("DRONE_SEMVER_PRERELEASE")
|
||||
if !ok || tagSuffix == "" {
|
||||
fmt.Println("DRONE_SEMVER_PRERELEASE doesn't exist for a tag, this is a release event...")
|
||||
return ReleaseMode, nil
|
||||
return ReleaseMode{Mode: TagMode}, nil
|
||||
}
|
||||
switch {
|
||||
case reBetaRls.MatchString(tagSuffix):
|
||||
return BetaReleaseMode, nil
|
||||
return ReleaseMode{Mode: TagMode, IsBeta: true}, nil
|
||||
case reTestRls.MatchString(tagSuffix):
|
||||
return TestReleaseMode, nil
|
||||
return ReleaseMode{Mode: TagMode, IsTest: true}, nil
|
||||
default:
|
||||
fmt.Printf("DRONE_SEMVER_PRERELEASE is custom string, release event with %s suffix\n", tagSuffix)
|
||||
return ReleaseMode, nil
|
||||
return ReleaseMode{Mode: TagMode}, nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user