-
Notifications
You must be signed in to change notification settings - Fork 17
/
main.go
81 lines (73 loc) · 1.76 KB
/
main.go
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package main
import (
"fmt"
"os"
"github.com/urfave/cli"
_ "github.com/joho/godotenv/autoload"
)
var build = "0" // build number set at compile-time
func main() {
app := cli.NewApp()
app.Name = "pypi plugin"
app.Usage = "pypi publish plugin"
app.Action = run
app.Version = fmt.Sprintf("0.0.%s", build)
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "repository",
Usage: "pypi repository URL",
Value: "https://upload.pypi.org/legacy/",
EnvVar: "PLUGIN_REPOSITORY",
},
cli.StringFlag{
Name: "username",
Usage: "pypi username",
Value: "guido",
EnvVar: "PLUGIN_USERNAME,PYPI_USERNAME",
},
cli.StringFlag{
Name: "password",
Usage: "pypi password",
Value: "secret",
EnvVar: "PLUGIN_PASSWORD,PYPI_PASSWORD",
},
cli.StringFlag{
Name: "setupfile",
Usage: "relative location of setup.py file",
Value: "setup.py",
EnvVar: "PLUGIN_SETUPFILE",
},
cli.StringSliceFlag{
Name: "distributions",
Usage: "distribution types to deploy",
EnvVar: "PLUGIN_DISTRIBUTIONS",
},
cli.BoolFlag{
Name: "skip_build",
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)
}
func run(c *cli.Context) {
plugin := Plugin{
Repository: c.String("repository"),
Username: c.String("username"),
Password: c.String("password"),
SetupFile: c.String("setupfile"),
Distributions: c.StringSlice("distributions"),
SkipBuild: c.Bool("skip_build"),
DistDir: c.String("dist_dir"),
}
if err := plugin.Exec(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}