-
Notifications
You must be signed in to change notification settings - Fork 26
/
cdeliveryboy-release.gradle
157 lines (135 loc) · 5.9 KB
/
cdeliveryboy-release.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
//Continuous Delivery release configuration with CDeliveryBoy
apply plugin: 'info.solidsoft.cdeliveryboy'
apply plugin: 'io.codearte.nexus-upload-staging'
cDeliveryBoy {
tasks {
uploadArchivesTask = "uploadArchivesStaging"
promoteRepositoryTask = "releaseRepository"
}
nexus {
autoPromote = true
}
}
nexusStaging {
packageGroup = "io.codearte"
stagingProfileId = "93c08fdebde1ff"
}
scmVersion {
versionIncrementer 'incrementMinor'
hooks {
pre 'fileUpdate', [file : 'README.md', pattern: { previousVersion, context -> /"io\.codearte\.gradle\.nexus:gradle-nexus-staging-plugin:$previousVersion"/ },
replacement: { currentVersion, context -> "\"io.codearte.gradle.nexus:gradle-nexus-staging-plugin:$currentVersion\"" }]
pre 'fileUpdate', [file : 'README.md', pattern: { previousVersion, context -> /id\ 'io\.codearte\.nexus-staging'\ version\ '$previousVersion'/ },
replacement: { currentVersion, context -> "id 'io.codearte.nexus-staging' version '$currentVersion'" }]
pre 'fileUpdate', [file : 'CHANGELOG.md', pattern: { previousVersion, context -> /^##\ ${context.currentVersion}\ -\ Unreleased$/ },
replacement: { currentVersion, context -> "## $currentVersion - ${new Date().format( 'yyyy-MM-dd' )}" }]
}
}
group = 'io.codearte.gradle.nexus'
//Beware: All release/version related changes should be put before that line which triggers (lazy) version evaluation
project.version = scmVersion.version
String repoSlug = "Codearte/gradle-nexus-staging-plugin"
modifyPom {
project {
name 'Gradle Nexus staging plugin'
description 'Gradle Nexus staging plugin'
url "https://github.com/${repoSlug}"
inceptionYear '2015'
scm {
url "https://github.com/${repoSlug}"
connection "scm:https://github.com/${repoSlug}.git"
developerConnection "scm:git://github.com/${repoSlug}.git"
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'szpak'
name 'Marcin Zajączkowski'
email 'mszpak ATT wp DOTT pl'
roles {
role 'developer'
role 'despot'
}
}
}
}
}
if (hasProperty('pluginPortal')) {
apply plugin: 'com.gradle.plugin-publish'
pluginBundle {
website = "https://github.com/${repoSlug}/"
vcsUrl = "https://github.com/${repoSlug}/"
plugins {
plugin {
id = 'io.codearte.nexus-staging'
displayName = 'gradle-nexus-staging-plugin'
description = 'Releasing to Maven Central from Gradle without dealing with Nexus UI'
tags = ['maven-central', 'nexus', 'release', 'binary', 'repository', 'staging', 'codearte']
}
uploadStagingPlugin {
id = 'io.codearte.nexus-upload-staging'
displayName = 'gradle-nexus-upload-staging-plugin'
description = 'DO NOT USE. Internal technical plugin for gradle-nexus-staging-plugin - see: io.codearte.nexus-staging'
tags = ['internal']
}
}
mavenCoordinates {
groupId = project.group
artifactId = project.name
}
}
publishPlugins {
onlyIf { ciBuild.inReleaseMode }
mustRunAfter releaseRepository
}
ciBuild.dependsOn publishPlugins
}
if (hasProperty('changelogSync')) {
task syncChangelog(type: Exec) {
doFirst { logger.info("Synchronizing changelog with GitHub for version ${project.version}") }
commandLine 'chandler', 'push', "release/${project.version}", '--tag-prefix=release/'
}
syncChangelog {
onlyIf { ciBuild.inReleaseMode }
mustRunAfter releaseRepository
if (project.tasks.findByName("publishPlugins")) {
mustRunAfter publishPlugins
}
}
ciBuild.dependsOn syncChangelog
}
//Some workarounds on CDeliveryBoy limitations - #3 and #13 (see below)
//Note. Referring non built-in types in external build script is problematic: https://github.com/gradle/gradle/issues/1262
//Note2. Task dependency removal is problematic due to: https://github.com/gradle/gradle/pull/6143/
["uploadArchives", "createRepository", "pointUploadArchivesToExplicitRepository"].each { String taskName ->
tasks.named(taskName).configure {
onlyIf {
boolean onlyIfValue = resolveOnlyIfValueForUploadTasks()
if (!onlyIfValue) {
logger.lifecycle("Task disabled due to environment settings for ciBuild")
}
return onlyIfValue
}
}
}
boolean resolveOnlyIfValueForUploadTasks() {
return !isSnapshotBuildWithSkipReleaseOnCI() && !isExtraBuildOfReleaseTagOnCI()
}
//Workaround on https://github.com/szpak/CDeliveryBoy/issues/3 - do not upload snapshots from other Java versions on CI server
boolean isSnapshotBuildWithSkipReleaseOnCI() {
return (project.version as String).endsWith("-SNAPSHOT") && System.env.SKIP_RELEASE == "true" && isCiBuildTaskCalled()
}
//Workaround on https://github.com/szpak/CDeliveryBoy/issues/13 - do not upload artifacts on extra build on CI server (e.g. from cron) of release tag
boolean isExtraBuildOfReleaseTagOnCI() {
return !(project.version as String).endsWith("-SNAPSHOT") && !ciBuild.inReleaseMode && isCiBuildTaskCalled()
}
boolean isCiBuildTaskCalled() {
//It covers only basic (idiomatic) case that "ciBuild" task has been called directly. Examining taskGraph would be better, however, more problematic due to late preparation.
return gradle.startParameter.taskNames.contains("ciBuild")
}