From b4ee866cf6273889651485a2564e890d7866b6db Mon Sep 17 00:00:00 2001 From: Adrian Sutton Date: Fri, 5 Jul 2019 15:21:09 +1000 Subject: [PATCH] Sanity check the generated distribution files before upload. (#1648) Also sanity check as part of build so we know if the checks start failing prior to the actual release. Signed-off-by: Adrian Sutton --- build.gradle | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/build.gradle b/build.gradle index 453f0a2302..e51de2b6bc 100644 --- a/build.gradle +++ b/build.gradle @@ -599,6 +599,25 @@ task releaseReferenceTest(type: Test, dependsOn: [ task releaseAcceptanceTest(type: Test, dependsOn: ':acceptance-tests:acceptanceTest') {} +tasks.register("verifyDistributions") { + dependsOn distTar + dependsOn distZip + def distTarFile = distTar.outputs.files.singleFile + def distZipFile = distZip.outputs.files.singleFile + def minDistributionSize = 20000000 + + // Sanity check the distributions by checking they are at least a reasonable size + doFirst { + if (distTarFile.length() < minDistributionSize) { + throw new GradleException("Distribution tar is suspiciously small: " + distTarFile.length() + " bytes") + } + if (distZipFile.length() < minDistributionSize) { + throw new GradleException("Distribution zip is suspiciously small: " + distZipFile.length() + " bytes") + } + } +} + + release { preTagCommitMessage = '[Gradle Release Plugin] - pre tag commit: ' tagCommitMessage = '[Gradle Release Plugin] - creating tag: ' @@ -633,6 +652,8 @@ bintray { pkg = bintrayPackage } +build.dependsOn verifyDistributions +bintrayUpload.dependsOn verifyDistributions afterReleaseBuild.dependsOn bintrayUpload bintrayUpload.mustRunAfter(distTar) bintrayUpload.mustRunAfter(distZip)