
@Library("platform") _

properties([disableConcurrentBuilds()])

//  from shared library - uses tags to set the platform name
//  (this is a pretty stupid way to set a parameter, but I don't
//  know of a better way to parameterize a multibranch pipeline)
platform = pypi_platform()
py_version = pypi_py_version()

currentBuild.description = "PyPI deployment " + platform

docker_image = "jenkins-manylinux2014_x86_64-pypi"
target = platform + ".whl"

node("master") {

  stage("Checkout sources") {
    checkout scm
  }

  stage("Building target ${target}") {

    sh("rm -rf wheelhouse ; mkdir -p wheelhouse")

    withDockerContainer(image: docker_image, args: "-v " + pwd() + ":/io") {
      sh("PY_VERSION=" + py_version + " /io/ci-scripts/docker/docker_build_jenkins.sh")
    }

  }
        
  stage("Publish and test") {
        
    //  publish for release tags
    if (BRANCH_NAME.startsWith('pypi_')) {
      sh("twine upload --skip-existing wheelhouse/klayout-*manylinux2014*.whl wheelhouse/*.zip")
    }

  }
        
}

