2022-05-03 20:03:37 +00:00
|
|
|
// Copyright (c) 2019, Drone Plugins project authors
|
|
|
|
// Copyright (c) 2021, Robert Kaussow <mail@thegeeklab.de>
|
|
|
|
|
2019-12-20 20:47:50 +00:00
|
|
|
// Use of this source code is governed by an Apache 2.0 license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
package urfave
|
|
|
|
|
|
|
|
import (
|
2022-05-03 20:03:37 +00:00
|
|
|
"github.com/thegeeklab/drone-plugin-lib/drone"
|
2019-12-20 20:47:50 +00:00
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
// semVerFlags has the cli.Flags for the drone.SemVer.
|
2022-05-29 11:15:31 +00:00
|
|
|
func semVerFlags(category string) []cli.Flag {
|
2019-12-20 20:47:50 +00:00
|
|
|
return []cli.Flag{
|
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "semver.version",
|
|
|
|
Usage: "semver version",
|
|
|
|
EnvVars: []string{
|
|
|
|
"DRONE_SEMVER",
|
|
|
|
},
|
2022-05-29 11:15:31 +00:00
|
|
|
Category: category,
|
2019-12-20 20:47:50 +00:00
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "semver.major",
|
|
|
|
Usage: "semver major",
|
|
|
|
EnvVars: []string{
|
|
|
|
"DRONE_SEMVER_MAJOR",
|
|
|
|
},
|
2022-05-29 11:15:31 +00:00
|
|
|
Category: category,
|
2019-12-20 20:47:50 +00:00
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "semver.minor",
|
|
|
|
Usage: "semver minor",
|
|
|
|
EnvVars: []string{
|
|
|
|
"DRONE_SEMVER_MINOR",
|
|
|
|
},
|
2022-05-29 11:15:31 +00:00
|
|
|
Category: category,
|
2019-12-20 20:47:50 +00:00
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "semver.patch",
|
|
|
|
Usage: "semver patch",
|
|
|
|
EnvVars: []string{
|
|
|
|
"DRONE_SEMVER_PATCH",
|
|
|
|
},
|
2022-05-29 11:15:31 +00:00
|
|
|
Category: category,
|
2019-12-20 20:47:50 +00:00
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "semver.prerelease",
|
|
|
|
Usage: "semver prerelease",
|
|
|
|
EnvVars: []string{
|
|
|
|
"DRONE_SEMVER_PRERELEASE",
|
|
|
|
},
|
2022-05-29 11:15:31 +00:00
|
|
|
Category: category,
|
2019-12-20 20:47:50 +00:00
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "semver.build",
|
|
|
|
Usage: "semver build",
|
|
|
|
EnvVars: []string{
|
|
|
|
"DRONE_SEMVER_BUILD",
|
|
|
|
},
|
2022-05-29 11:15:31 +00:00
|
|
|
Category: category,
|
2019-12-20 20:47:50 +00:00
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "semver.short",
|
|
|
|
Usage: "semver short",
|
|
|
|
EnvVars: []string{
|
|
|
|
"DRONE_SEMVER_SHORT",
|
|
|
|
},
|
2022-05-29 11:15:31 +00:00
|
|
|
Category: category,
|
2019-12-20 20:47:50 +00:00
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "semver.error",
|
|
|
|
Usage: "semver error",
|
|
|
|
EnvVars: []string{
|
|
|
|
"DRONE_SEMVER_ERROR",
|
|
|
|
},
|
2022-05-29 11:15:31 +00:00
|
|
|
Category: category,
|
2019-12-20 20:47:50 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-10 20:19:39 +00:00
|
|
|
// semVerFromContext creates a drone.SemVer from the cli.Context.
|
2019-12-20 20:47:50 +00:00
|
|
|
func semVerFromContext(ctx *cli.Context) drone.SemVer {
|
|
|
|
return drone.SemVer{
|
|
|
|
Version: ctx.String("semver.version"),
|
|
|
|
Major: ctx.String("semver.major"),
|
|
|
|
Minor: ctx.String("semver.minor"),
|
|
|
|
Patch: ctx.String("semver.patch"),
|
|
|
|
Prerelease: ctx.String("semver.prerelease"),
|
|
|
|
Build: ctx.String("semver.build"),
|
|
|
|
Short: ctx.String("semver.short"),
|
|
|
|
Error: ctx.String("semver.error"),
|
|
|
|
}
|
|
|
|
}
|