From 0e0ddeaf4e9144427fa0c0a13f5926b00faae110 Mon Sep 17 00:00:00 2001 From: TomVasile <43349666+TomVasile@users.noreply.github.com> Date: Tue, 21 Apr 2020 19:24:41 +0000 Subject: [PATCH 1/4] fix build dependencies; look for dist in nested dir; --- plugin.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin.go b/plugin.go index 796ccf3..c98f2b0 100644 --- a/plugin.go +++ b/plugin.go @@ -3,6 +3,7 @@ package main import ( "log" "os/exec" + "path/filepath" "github.com/pkg/errors" ) @@ -40,7 +41,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(filepath.Dir(p.SetupFile), "dist/*")) return exec.Command("twine", args...) } From f140ca382801937af7bef9577a9c8e348230bddd Mon Sep 17 00:00:00 2001 From: TomVasile <43349666+TomVasile@users.noreply.github.com> Date: Tue, 21 Apr 2020 21:17:04 +0000 Subject: [PATCH 2/4] Introduce optional flag for dist directory --- main.go | 7 +++++++ plugin.go | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) 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 c98f2b0..8fe36fa 100644 --- a/plugin.go +++ b/plugin.go @@ -16,6 +16,7 @@ type Plugin struct { SetupFile string Distributions []string SkipBuild bool + DistDir string } func (p Plugin) buildCommand() *exec.Cmd { @@ -41,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, filepath.Join(filepath.Dir(p.SetupFile), "dist/*")) + args = append(args, filepath.Join(filepath.Dir(p.DistDir), "/*")) return exec.Command("twine", args...) } From 2ad3a3d8613208584f80917cd8daa0a9f0455bf6 Mon Sep 17 00:00:00 2001 From: TomVasile <43349666+TomVasile@users.noreply.github.com> Date: Tue, 21 Apr 2020 21:27:59 +0000 Subject: [PATCH 3/4] add flag to test case --- plugin_test.go | 1 + 1 file changed, 1 insertion(+) 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 { From f001295cbbb61d66267218d50d45554c697f1f15 Mon Sep 17 00:00:00 2001 From: TomVasile <43349666+TomVasile@users.noreply.github.com> Date: Wed, 29 Apr 2020 16:34:46 +0000 Subject: [PATCH 4/4] simplify distdir filepath --- plugin.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.go b/plugin.go index 8fe36fa..b80474b 100644 --- a/plugin.go +++ b/plugin.go @@ -42,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, filepath.Join(filepath.Dir(p.DistDir), "/*")) + args = append(args, filepath.Join(p.DistDir, "/*")) return exec.Command("twine", args...) }