Skip to content

Commit

Permalink
Merge pull request #16 from kritika-singh3/upgrade-release-tasks
Browse files Browse the repository at this point in the history
Utilising the helper.gradle for github release
  • Loading branch information
Bhupendra authored May 7, 2019
2 parents 01109ed + d86f761 commit bd7e3bc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 123 deletions.
129 changes: 19 additions & 110 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,128 +14,37 @@
* limitations under the License.
*/

plugins {
id 'co.riiid.gradle' version '0.4.2'
}

def gitRevision = { ->
def hashStdOut = new ByteArrayOutputStream()
exec {
commandLine "git", "log", "-n", "1", "--format=%H"
standardOutput = hashStdOut
apply from: "https://raw.githubusercontent.com/gocd/gocd-plugin-gradle-task-helpers/master/helper.gradle?_=${(int) (new Date().toInstant().epochSecond / 60)}"

gocdPlugin {
id = 'yum'
pluginVersion = '2.0.3'
goCdVersion = '15.2.0'
name = 'Yum Plugin'
description = 'Plugin that polls a yum repository'
vendorName = 'ThoughtWorks Go Team'
vendorUrl = 'https://github.com/gocd/gocd-yum-repository-poller-plugin'

githubRepo {
owner = System.getenv('GITHUB_USER') ?: 'bob'
repo = 'gocd-yum-repository-poller-plugin'
token = System.getenv('GITHUB_TOKEN') ?: 'bad-token'
}

return hashStdOut.toString().trim()
}

def releaseRevision = { ->
def hashStdOut = new ByteArrayOutputStream()
exec {
commandLine "git", "log", "--pretty=format:"
standardOutput = hashStdOut
}
pluginProject = project(':gocd-yum-repo-plugin')

return hashStdOut.size().toString()
prerelease = !"No".equalsIgnoreCase(System.getenv('PRERELEASE'))
assetsToRelease = [project(':gocd-yum-repo-plugin').tasks.findByName('jar')]
}

def PLUGIN_VERSION = '2.0.3'
def DIST_VERSION = releaseRevision()
def GIT_REVISION = gitRevision()

allprojects {
project.ext.distVersion = DIST_VERSION
project.ext.fullVersion = DIST_VERSION ? "${PLUGIN_VERSION}-${DIST_VERSION}" : PLUGIN_VERSION
project.ext.gitRevision = GIT_REVISION
project.ext.pluginDesc = [
id : 'yum',
version : PLUGIN_VERSION,
goCdVersion: '15.2.0',
name : 'Yum Plugin',
description: 'Plugin that polls a yum repository',
vendorName : 'ThoughtWorks Go Team',
vendorUrl : 'https://www.thoughtworks.com'
]

group = 'cd.go'
version = project.fullVersion
version = gocdPlugin.fullVersion(project)
}

subprojects {
apply plugin: 'java'
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
jcenter()
mavenLocal()
}

tasks.withType(Jar) { jarTask ->
preserveFileTimestamps = false
reproducibleFileOrder = true
['MD5', 'SHA1', 'SHA-256'].each { algo ->
jarTask.outputs.files("${jarTask.archivePath}.${algo}")
jarTask.doLast {
ant.checksum file: jarTask.archivePath, format: 'MD5SUM', algorithm: algo
}
}

manifest {
attributes(
'Go-Version': project.pluginDesc.goCdVersion,
'Plugin-Revision': project.pluginDesc.version,
'Implementation-Title': project.name,
'Implementation-Version': project.version,
'Source-Compatibility': project.sourceCompatibility,
'Target-Compatibility': project.targetCompatibility,
'Git-SHA': GIT_REVISION
)
}
}

tasks.withType(JavaCompile) { compileTask ->
options.encoding = "UTF-8"
}

tasks.withType(Test) {
outputs.upToDateWhen { false }
testLogging {
showStandardStreams = project.path != ':server'

exceptionFormat 'full'

beforeSuite { suite ->
if (suite.parent) {
logger.quiet("Running ${suite.name}")
}
}

afterSuite { suite, result ->
if (suite.parent) {
logger.quiet("Tests run: ${result.testCount}, Failures: ${result.failedTestCount}, Skipped: ${result.skippedTestCount}, Time elapsed: ${(result.endTime - result.startTime) / 1000.00} sec")
if (result.resultType == TestResult.ResultType.FAILURE) {
logger.quiet("Test ${suite.name} FAILED")
}
} else {
logger.quiet("Total tests run: ${result.testCount}, Failures: ${result.failedTestCount}, Skipped: ${result.skippedTestCount}, Time elapsed: ${(result.endTime - result.startTime) / 1000.00} sec")
}
}
}
}
}

github {
owner = System.getenv('GITHUB_USER') ?: 'bob'
repo = 'gocd-yum-repository-poller-plugin'
token = System.getenv('GITHUB_TOKEN') ?: 'bad-token'
tagName = PLUGIN_VERSION
name = PLUGIN_VERSION
targetCommitish = project.gitRevision
body = """
# Version ${fullVersion}
See release notes at https://github.com/${github.owner}/${github.repo}/blob/master/CHANGELOG.md#${github.tagName.replaceAll(/[^A-Za-z0-9]/, '')}
""".stripIndent().trim()

assets = project(':gocd-yum-repo-plugin').jar.outputs.files.files
}
13 changes: 0 additions & 13 deletions gocd-yum-repo-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/


dependencies {
compile project(':plugin-common')
compileOnly group: 'cd.go.plugin', name: 'go-plugin-api', version: '17.7.0'
Expand All @@ -37,18 +36,6 @@ sourceSets {
}
}

processResources {
from("src/main/resource-templates") {
filesMatching('plugin.xml') {
expand project.pluginDesc
}

filesMatching('plugin.properties') {
expand project.pluginDesc
}
}
}

jar {

from(configurations.compile) {
Expand Down

0 comments on commit bd7e3bc

Please sign in to comment.