grafana/pkg/build/cmd/exportversion.go
Dimitris Sotirakis ac0f5c5556
CI: Add export-version command (#55072)
* Add export-version command

* Fix lint

* 1-line cleanup
2022-09-13 13:26:24 +03:00

31 lines
514 B
Go

package main
import (
"os"
"path/filepath"
"github.com/urfave/cli/v2"
)
func ExportVersion(c *cli.Context) error {
metadata, err := GenerateMetadata(c)
if err != nil {
return err
}
const distDir = "dist"
if err := os.RemoveAll(distDir); err != nil {
return err
}
if err := os.Mkdir(distDir, 0750); err != nil {
return err
}
// nolint:gosec
if err := os.WriteFile(filepath.Join(distDir, "grafana.version"), []byte(metadata.GrafanaVersion), 0664); err != nil {
return err
}
return nil
}