Repository navigation
Expand file tree
/
Copy pathbump-plugin.go
More file actions
62 lines (56 loc) · 2.37 KB
/
Copy pathbump-plugin.go
File metadata and controls
62 lines (56 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright The Perses Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package main
import (
"flag"
"github.com/perses/perses/scripts/pkg/command"
"github.com/sirupsen/logrus"
)
func bump(pluginName, bumpType, preID string) error {
if pluginName == "" {
if preID == "" {
return command.Run("npm", "version", bumpType, "--workspaces", "--no-git-tag-version")
}
return command.Run("npm", "version", bumpType, "--workspaces", "--preid", preID, "--no-git-tag-version")
}
if preID == "" {
return command.Run("npm", "version", bumpType, "--workspace", pluginName, "--no-git-tag-version")
}
return command.Run("npm", "version", bumpType, "--workspace", pluginName, "--preid", preID, "--no-git-tag-version")
}
func main() {
bumpAll := flag.Bool("all", false, `bump all the plugins versions to the next minor version.
You can also reuse it to create and update beta, rc, ...
# Creation of the first beta
go run ./scripts/bump-plugin --all --type preminor --preid beta
# Following betas
go run ./scripts/bump-plugin --all --type prerelease --preid beta`)
bumpSinglePlugin := flag.String("name", "", "bump a single plugin to the next minor version")
bumpType := flag.String("type", "minor", "the type of version bump (major, minor, patch)")
bumpPreID := flag.String("preid", "", "the preid for the version bump (alpha, beta, rc)")
flag.Parse()
if !*bumpAll {
if len(*bumpSinglePlugin) == 0 {
logrus.Fatal("you must provide a plugin name if the --all flag is not set")
}
logrus.Infof("bumping %s", *bumpSinglePlugin)
if err := bump(*bumpSinglePlugin, *bumpType, *bumpPreID); err != nil {
logrus.WithError(err).Fatalf("unable to bump the version of the plugin %s", *bumpSinglePlugin)
}
return
}
logrus.Info("bumping all the plugins")
if err := bump("", *bumpType, *bumpPreID); err != nil {
logrus.WithError(err).Fatal("unable to bump the versions of the plugins")
}
}