Skip to content

Commit d695b59

Browse files
committed
Don't rebuild on TC upload build
1 parent 7627950 commit d695b59

File tree

2 files changed

+45
-25
lines changed

2 files changed

+45
-25
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ conda-pip-build/
88
**/build/
99
*.DS_Store
1010
gradle.properties
11-
VERSION
11+
teamcity-artifacts

build.gradle

+44-24
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ allprojects {
4444
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlinVersion"
4545
}
4646

47+
ext.teamcityArtifactsPath = "teamcity-artifacts"
48+
ext.tcDir = rootDir.toPath().resolve(ext.teamcityArtifactsPath)
49+
ext.isTeamcityBuild = ext.tcDir.toFile().exists()
50+
4751
String defaultVersion = '0.7.15'
4852
project.ext.isProtectedBranch = isProtectedBranch()
4953
String buildCounterStr = rootProject.ext.has('build.counter') ?
@@ -58,7 +62,7 @@ allprojects {
5862
ext.versionFileName = "VERSION"
5963

6064
if (!Pattern.matches(buildNumberRegex, buildNumber)) {
61-
def versionFile = rootDir.toPath().resolve(ext.versionFileName).toFile()
65+
def versionFile = ext.tcDir.resolve(ext.versionFileName).toFile()
6266
if (versionFile.exists()) {
6367
def lines = versionFile.readLines()
6468
assert !lines.empty, "There should be at least one line in VERSION file"
@@ -367,7 +371,7 @@ class CondaTaskSpec extends TaskSpec {
367371
String password
368372
}
369373

370-
def condaTaskSpecs = new UploadTaskSpecs<CondaTaskSpec>(
374+
ext.condaTaskSpecs = new UploadTaskSpecs<CondaTaskSpec>(
371375
project: project,
372376
stable: new CondaTaskSpec(
373377
taskName: "condaUploadStable",
@@ -381,27 +385,37 @@ def condaTaskSpecs = new UploadTaskSpecs<CondaTaskSpec>(
381385
protectedDeployTaskName: "condaUploadProtected"
382386
)
383387

384-
condaTaskSpecs.createTasks { taskSpec ->
385-
task([dependsOn: [cleanInstallDirConda, condaPackage]], taskSpec.taskName) {
386-
doLast {
387-
exec {
388-
commandLine 'anaconda', 'login',
389-
'--username', condaTaskSpecs.stable.username,
390-
'--password', condaTaskSpecs.stable.password
391-
standardInput new ByteArrayInputStream("yes".bytes)
392-
}
388+
void doCondaUpload(CondaTaskSpec taskSpec, java.nio.file.Path artifactPath) {
389+
exec {
390+
commandLine 'anaconda', 'login',
391+
'--username', condaTaskSpecs.stable.username,
392+
'--password', condaTaskSpecs.stable.password
393+
standardInput new ByteArrayInputStream("yes".bytes)
394+
}
393395

394-
Files.walk(getSubdir(condaBuildDir, condaPackageDir, "noarch")).withCloseable { stream ->
395-
def artifact = stream
396-
.filter { Files.isRegularFile(it) && it.fileName.toString().endsWith(".tar.bz2") }
397-
.findFirst()
398-
assert artifact.isPresent(), ".tar.bz2 file should be present in package/noarch dir"
396+
Files.walk(artifactPath).withCloseable { stream ->
397+
def artifact = stream
398+
.filter { Files.isRegularFile(it) && it.fileName.toString().endsWith(".tar.bz2") }
399+
.findFirst()
400+
assert artifact.isPresent(), ".tar.bz2 file should be present in package/noarch dir"
399401

400-
def artifactPath = artifact.get().toAbsolutePath().toString()
401-
exec {
402-
commandLine('anaconda', 'upload', '-u', taskSpec.username, artifactPath)
403-
}
404-
}
402+
def artifactFilePath = artifact.get().toAbsolutePath().toString()
403+
exec {
404+
commandLine('anaconda', 'upload', '-u', taskSpec.username, artifactFilePath)
405+
}
406+
}
407+
}
408+
409+
condaTaskSpecs.createTasks { taskSpec ->
410+
task(taskSpec.taskName) {
411+
def artifactsDir = tcDir
412+
if (!isTeamcityBuild) {
413+
artifactsDir = getSubdir(condaBuildDir, condaPackageDir, "noarch")
414+
dependsOn([cleanInstallDirConda, condaPackage])
415+
}
416+
417+
doLast {
418+
doCondaUpload(taskSpec, artifactsDir)
405419
}
406420
}
407421
}
@@ -436,12 +450,18 @@ def pyPiTaskSpecs = new UploadTaskSpecs<PyPiTaskSpec>(
436450
)
437451

438452
pyPiTaskSpecs.createTasks { taskSpec ->
439-
task([type: Exec, dependsOn: [pyPiPackage]], taskSpec.taskName) {
453+
task([type: Exec], taskSpec.taskName) {
454+
if (!isTeamcityBuild) {
455+
dependsOn([pyPiPackage])
456+
workingDir(condaBuildDir.resolve("dist"))
457+
} else {
458+
workingDir(tcDir)
459+
}
460+
440461
commandLine "twine", "upload",
441462
"-u", taskSpec.username,
442463
"-p", taskSpec.password,
443464
"--repository-url", taskSpec.repoURL,
444-
"dist/*"
445-
workingDir condaBuildDir
465+
"*.whl"
446466
}
447467
}

0 commit comments

Comments
 (0)