| apply plugin: "org.shipkit.shipkit-auto-version" |
| apply plugin: "org.shipkit.shipkit-changelog" |
| apply plugin: "org.shipkit.shipkit-github-release" |
| |
| tasks.named("generateChangelog") { |
| previousRevision = project.ext.'shipkit-auto-version.previous-tag' |
| githubToken = System.getenv("GITHUB_TOKEN") |
| repository = "mockito/mockito" |
| } |
| |
| tasks.named("githubRelease") { |
| def genTask = tasks.named("generateChangelog").get() |
| dependsOn genTask |
| repository = genTask.repository |
| changelog = genTask.outputFile |
| newTagRevision = System.getenv("GITHUB_SHA") |
| githubToken = System.getenv("GITHUB_TOKEN") |
| } |
| |
| /** |
| * Mockito team does not publish to Maven Central every release as requested by the community. |
| * We publish to maven central only some versions. All versions are published to Bintray on every change. |
| * See https://github.com/mockito/mockito/issues/911 |
| */ |
| ext.mavenCentralRelease = shouldReleaseToCentral(project) |
| |
| /** |
| * Finds out if we should release to Maven Central. |
| * To test this logic, run build with '-i' (info logging) and inspect the build output. |
| */ |
| static boolean shouldReleaseToCentral(project) { |
| boolean centralReleaseByCommit = 'true' == System.getenv("MAVEN_CENTRAL_RELEASE") |
| boolean centralReleaseByProjectProperty = project.hasProperty("maven-central-release") |
| boolean centralRelease = centralReleaseByCommit || centralReleaseByProjectProperty |
| def message = """Bintray publish was using following settings: |
| - commit message contains '[ci maven-central-release]': $centralReleaseByCommit |
| - project property 'maven-central-release' exists: $centralReleaseByProjectProperty |
| - Maven Central release is enabled: $centralRelease""" |
| project.logger.info(message) |
| project.afterEvaluate { |
| project.tasks.bintrayPublish.doLast { logger.lifecycle(message) } |
| } |
| return centralRelease |
| } |