Initial commit, haven't tested yet

This commit is contained in:
swgillespie 2014-03-27 22:43:58 -07:00
parent 070caa3833
commit 44aaf4fd9c
2 changed files with 41 additions and 0 deletions

View file

@ -10,6 +10,7 @@ import (
type Publish struct {
S3 *S3 `yaml:"s3,omitempty"`
Swift *Swift `yaml:"swift,omitempty"`
PyPI *PyPI `yaml:"pypi, omitempty"`
}
func (p *Publish) Write(f *buildfile.Buildfile) {
@ -19,4 +20,7 @@ func (p *Publish) Write(f *buildfile.Buildfile) {
if p.Swift != nil {
p.Swift.Write(f)
}
if p.PyPI != nil {
p.PyPI.Write(f)
}
}

View file

@ -1 +1,38 @@
package publish
import (
"fmt"
"github.com/drone/drone/pkg/build/buildfile"
)
// set up the .pypirc file
var pypirc = `
cat <<EOF > $HOME/.pypirc
[pypirc]
servers = pypi
[server-login]
username:%s
password:%s
EOF`
type PyPI struct {
Username string `yaml:"username,omitempty"`
Password string `yaml:"password,omitempty"`
}
func (p *PyPI) Write(f *buildfile.Buildfile) {
if len(p.Username) == 0 || len(p.Password) == 0 {
// nothing to do if the config is bad
return
}
f.WriteCmdSilent("echo 'publishing to PyPI...'")
// find the setup.py file
f.WriteCmdSilent("_PYPI_SETUP_PY=$(find . -name 'setup.py')")
f.WriteCmdSilent(fmt.Sprintf(pypirc, p.Username, p.Password))
// if we found the setup.py file use it to deploy
f.WriteCmd("[ -z $_PYPI_SETUP_PY ] || python $_PYPI_SETUP_PY sdist --formats gztar,zip upload")
f.WriteCmd("[ -z $_PYPI_SETUP_PY ] && echo 'Failed to find setup.py file'")
}