mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-12 08:23:48 +02:00
Initial commit, haven't tested yet
This commit is contained in:
parent
070caa3833
commit
44aaf4fd9c
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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'")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user