This repository has been archived by the owner on Feb 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
76dfc20
commit 31eb2e6
Showing
2 changed files
with
115 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,128 @@ | ||
apply plugin: 'com.gradle.plugin-publish' | ||
apply plugin: 'com.novoda.bintray-release' | ||
apply plugin: 'org.ajoberstar.grgit' | ||
apply plugin: 'org.ajoberstar.github-pages' | ||
|
||
ext { | ||
websiteUrl = 'https://github.com/novoda/gradle-build-properties-plugin' | ||
} | ||
|
||
version = '0.3' | ||
String tag = "v$project.version" | ||
groovydoc.docTitle = 'Build Properties Plugin' | ||
|
||
publish { | ||
userOrg = 'novoda' | ||
groupId = 'com.novoda' | ||
artifactId = 'gradle-build-properties-plugin' | ||
publishVersion = project.version | ||
website = 'https://github.com/novoda/gradle-build-properties-plugin' | ||
website = websiteUrl | ||
} | ||
|
||
githubPages { | ||
commitMessage = "Deploy groovydoc for release $tag" | ||
pages { | ||
from groovydoc.destinationDir | ||
into "docs/${project.version}" | ||
} | ||
} | ||
|
||
pluginBundle { | ||
website = websiteUrl | ||
vcsUrl = websiteUrl | ||
description = 'A Gradle plugin to consume external build properties.' | ||
tags = ['java', 'android', 'gradle', 'build properties', 'project properties', "system properties"] | ||
|
||
plugins { | ||
gradleBuildPropertiesPlugin { | ||
id = 'com.novoda.build-properties' | ||
displayName = 'Gradle build properties plugin' | ||
} | ||
} | ||
} | ||
|
||
task prepareGhCredentials { | ||
description = 'Prepare GitHub credentials' | ||
group = 'release' | ||
doLast { | ||
String username = System.getenv()['GITHUB_USERNAME'] | ||
String password = System.getenv()['GITHUB_TOKEN'] | ||
System.properties['org.ajoberstar.grgit.auth.username'] = username | ||
System.properties['org.ajoberstar.grgit.auth.password'] = password | ||
} | ||
} | ||
|
||
prepareGhPages.dependsOn groovydoc | ||
publishGhPages.dependsOn prepareGhCredentials | ||
|
||
task prepareGradlePluginsRepoRelease { | ||
doLast { | ||
System.properties['gradle.publish.key'] = System.getenv()['GRADLE_PLUGINS_REPO_KEY'] | ||
System.properties['gradle.publish.secret'] = System.getenv()['GRADLE_PLUGINS_REPO_SECRET'] | ||
} | ||
} | ||
|
||
task prepareRelease { | ||
description = 'Prepare changelog and tag for release' | ||
group = 'release' | ||
dependsOn prepareGhPages, prepareGhCredentials, prepareGradlePluginsRepoRelease | ||
doLast { | ||
String changelog = extractChangelog() | ||
grgit.tag.add { | ||
name = tag | ||
message = "Release $tag\n\n$changelog" | ||
} | ||
} | ||
} | ||
|
||
String extractChangelog() { | ||
String fullChangelog = rootProject.file('CHANGELOG.md').text | ||
def latestChangelog = (fullChangelog =~ /\[Version ${project.version}.*\n-*([\s\S]*?)\[Version.*\n-*/) | ||
if (latestChangelog.size() > 0) { | ||
return latestChangelog[0][1].trim() | ||
} | ||
|
||
def firstChangelog = (fullChangelog =~ /\[Version ${project.version}.*\n-*([\s\S]*)/) | ||
if (firstChangelog.size() > 0) { | ||
return firstChangelog[0][1].trim() | ||
} | ||
throw new GradleException("No changelog found for version $project.version") | ||
} | ||
|
||
task printChangelog { | ||
group = 'help' | ||
description = "Print the provisional changelog for version $project.version" | ||
doLast { | ||
println "\nChangelog for version $project.version:\n${extractChangelog()}\n" | ||
} | ||
} | ||
|
||
task publishArtifact { | ||
description = "Publish artifact for plugin version: $tag" | ||
group = 'release' | ||
project.afterEvaluate { dependsOn bintrayUpload } | ||
mustRunAfter prepareRelease | ||
} | ||
|
||
task publishGroovydoc { | ||
description = "Deploy groovydoc for plugin version: $tag" | ||
group = 'release' | ||
dependsOn publishGhPages | ||
mustRunAfter publishArtifact | ||
} | ||
|
||
task publishRelease { | ||
description = "Publish release for plugin version: $tag" | ||
group = 'release' | ||
|
||
if (project.hasProperty('dryRun') && project['dryRun'] == 'false') { | ||
dependsOn bintrayUpload | ||
dependsOn prepareRelease, publishArtifact, publishGroovydoc, publishPlugins | ||
doLast { | ||
grgit.push { | ||
tags = true | ||
} | ||
} | ||
} else { | ||
dependsOn publishArtifact | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters