diff --git a/main.go b/main.go index 490572b..ffa028d 100644 --- a/main.go +++ b/main.go @@ -52,6 +52,12 @@ func main() { Usage: "skip build and only upload pre-build packages", EnvVar: "PLUGIN_SKIP_BUILD", }, + cli.StringFlag{ + Name: "dist_dir", + Usage: "used when distribution directory is not in build root", + Value: "dist/", + EnvVar: "PLUGIN_DIST_DIR", + }, } app.Run(os.Args) @@ -65,6 +71,7 @@ func run(c *cli.Context) { SetupFile: c.String("setupfile"), Distributions: c.StringSlice("distributions"), SkipBuild: c.Bool("skip_build"), + DistDir: c.String("dist_dir"), } if err := plugin.Exec(); err != nil { diff --git a/plugin.go b/plugin.go index 796ccf3..b80474b 100644 --- a/plugin.go +++ b/plugin.go @@ -3,6 +3,7 @@ package main import ( "log" "os/exec" + "path/filepath" "github.com/pkg/errors" ) @@ -15,6 +16,7 @@ type Plugin struct { SetupFile string Distributions []string SkipBuild bool + DistDir string } func (p Plugin) buildCommand() *exec.Cmd { @@ -40,7 +42,7 @@ func (p Plugin) uploadCommand() *exec.Cmd { args = append(args, p.Username) args = append(args, "--password") args = append(args, p.Password) - args = append(args, "dist/*") + args = append(args, filepath.Join(p.DistDir, "/*")) return exec.Command("twine", args...) } diff --git a/plugin_test.go b/plugin_test.go index f0e22af..929ed44 100644 --- a/plugin_test.go +++ b/plugin_test.go @@ -17,6 +17,7 @@ func TestPublish(t *testing.T) { SetupFile: "testdata/setup.py", Distributions: strings.Split(os.Getenv("PLUGIN_DISTRIBUTIONS"), " "), SkipBuild: false, + DistDir: "dist/", } err := plugin.Exec() if err != nil {