diff --git a/DOCS.md b/DOCS.md index e27b688..f87c006 100644 --- a/DOCS.md +++ b/DOCS.md @@ -11,6 +11,8 @@ The following parameters are used to configure the plugin: * **registry** - the registry URL to use (https://registry.npmjs.org by default) * **folder** - the folder, relative to the workspace, containing the library (uses the workspace directory, by default) +* **tag** - the tag to use when publishing the package (does not set + one by default) The following secret values can be set to configure the plugin. diff --git a/main.go b/main.go index e57ece9..a9edc2c 100644 --- a/main.go +++ b/main.go @@ -58,6 +58,11 @@ func main() { Name: "env-file", Usage: "source env file", }, + cli.StringFlag{ + Name: "tag", + Usage: "NPM publish tag", + EnvVar: "PLUGIN_TAG", + }, } if err := app.Run(os.Args); err != nil { @@ -79,6 +84,7 @@ func run(c *cli.Context) error { Registry: c.String("registry"), Folder: c.String("folder"), SkipVerify: c.Bool("skip_verify"), + Tag: c.String("tag"), }, } diff --git a/plugin.go b/plugin.go index 295dbc0..790b3d5 100644 --- a/plugin.go +++ b/plugin.go @@ -26,6 +26,7 @@ type ( Registry string Folder string SkipVerify bool + Tag string } npmPackage struct { @@ -81,7 +82,7 @@ func (p Plugin) Exec() error { log.Info("Publishing package") // run the publish command - return runCommand(publishCommand(), p.Config.Folder) + return runCommand(publishCommand(p.Config), p.Config.Folder) } return nil @@ -307,8 +308,12 @@ func packageVersionsCommand(name string) *exec.Cmd { } // publishCommand runs the publish command -func publishCommand() *exec.Cmd { - return exec.Command("npm", "publish") +func publishCommand(config Config) *exec.Cmd { + if len(config.Tag) == 0 { + return exec.Command("npm", "publish"); + } else { + return exec.Command("npm", "publish", "--tag", config.Tag); + } } // trace writes each command to standard error (preceded by a ‘$ ’) before it