Skip to content

Commit 89a6122

Browse files
committed
Added bintrayUpload task for releasing
1 parent f631e92 commit 89a6122

File tree

2 files changed

+111
-15
lines changed

2 files changed

+111
-15
lines changed

docs/RELEASING.adoc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,9 @@ Create a https://github.com/TWCable/grabbit/releases/new[new GitHub release], se
3232

3333
== Upload to BinTray
3434

35-
. https://bintray.com/twcable/aem/Grabbit/new/version[Create a new version record] ("`Name`" is the version without the "v". Leave "`Description`" blank)
36-
. Fill in the "`Version Details`" -- most notably the "`VCS tag`". Everything else will be inherited from the main project metadata.
37-
. Using your BinTray username and https://bintray.com/profile/edit[your API key], use the following curl command with appropriate substitutions:
38-
3935
[source,bash]
4036
--
41-
curl -u ${USER_NAME}:${API_KEY} -T grabbit/build/distributions/grabbit-${VERSION}.zip -X PUT https://bintray.com/api/v1/content/twcable/aem/Grabbit/${VERSION}/grabbit-${VERSION}.zip\?publish\=1
37+
$ ./gradlew bintrayUpload
4238
--
39+
40+
If you have not yet set up your credentials, the task will tell you what to do.

grabbit/build.gradle

Lines changed: 108 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
plugins {
2+
id "com.jfrog.bintray" version "1.3.1"
3+
}
4+
15
apply from: "${rootProject.projectDir}/gradle/verifyComponentConfig.gradle"
26
apply from: "${rootProject.projectDir}/gradle/utils.gradle"
37

@@ -23,7 +27,7 @@ createPackage.bundleInstallRoot = '/apps/grabbit/install'
2327
bundle.installPath = '/apps/grabbit/install'
2428

2529
jar {
26-
from ('src/main/content/SLING-INF/content', {
30+
from('src/main/content/SLING-INF/content', {
2731
into 'SLING-INF/content'
2832
})
2933
}
@@ -66,7 +70,6 @@ jar.manifest {
6670
instruction 'Import-Package', "sun.misc"
6771
instruction 'Import-Package', '*'
6872

69-
7073
// export everything to OSGi except *.impl packages
7174
instruction 'Export-Package', "!*.impl, *;-noimport:=false;version=${version}"
7275
}
@@ -109,14 +112,109 @@ idea {
109112
// The whole build dir is excluded by default, but we need build/generated-sources,
110113
// which contains the generated proto classes.
111114
excludeDirs = [
112-
file("$buildDir/classes"),
113-
file("$buildDir/docs"),
114-
file("$buildDir/dependency-cache"),
115-
file("$buildDir/libs"),
116-
file("$buildDir/reports"),
117-
file("$buildDir/resources"),
118-
file("$buildDir/test-results"),
119-
file("$buildDir/tmp"),
115+
file("$buildDir/classes"),
116+
file("$buildDir/docs"),
117+
file("$buildDir/dependency-cache"),
118+
file("$buildDir/libs"),
119+
file("$buildDir/reports"),
120+
file("$buildDir/resources"),
121+
file("$buildDir/test-results"),
122+
file("$buildDir/tmp"),
120123
]
121124
}
122125
}
126+
127+
gradle.taskGraph.whenReady { taskGraph ->
128+
if (taskGraph.hasTask(bintrayUpload)) {
129+
if (!project.hasProperty('bintray.user') || !project.hasProperty('bintray.key')) {
130+
throw new IllegalArgumentException((String)"Please define 'bintray.user' and " +
131+
"'bintray.key' properties. (Such as in ~/.gradle/gradle.properties)")
132+
}
133+
}
134+
}
135+
136+
version = new Version(version as String)
137+
138+
bintray {
139+
user = project.properties['bintray.user']
140+
key = project.properties['bintray.key']
141+
filesSpec {
142+
from tasks.getByPath('createPackage').archivePath
143+
into '.'
144+
}
145+
146+
publish = version.status == 'release'
147+
148+
pkg {
149+
userOrg = 'twcable'
150+
repo = 'aem'
151+
name = 'Grabbit'
152+
153+
desc = 'The purpose of this project is to provide a reliable and fast solution for copying content from a Source to Destination. Source and destination can be any AEM instances.'
154+
155+
websiteUrl = 'https://github.com/TWCable/grabbit'
156+
issueTrackerUrl = 'https://github.com/TWCable/grabbit/issues'
157+
vcsUrl = 'https://github.com/TWCable/grabbit.git'
158+
licenses = ['Apache-2.0']
159+
labels = ['AEM', 'CQ', 'Content Copy', 'Data Migration']
160+
attributes = ['plat': ['aem', 'cq']]
161+
162+
publicDownloadNumbers = true
163+
164+
//noinspection GroovyAssignabilityCheck
165+
version {
166+
//noinspection GrReassignedInClosureLocalVar
167+
name = project.version.bintrayVersion
168+
vcsTag = 'v' + project.version
169+
}
170+
}
171+
}
172+
173+
bintrayUpload.dependsOn('createPackage')
174+
175+
// **************************************************************************
176+
//
177+
// VERSION CLASS
178+
//
179+
// **************************************************************************
180+
181+
class Version {
182+
String originalVersion
183+
String thisVersion
184+
String status
185+
Date buildTime
186+
187+
188+
Version(String versionValue) {
189+
buildTime = new Date()
190+
originalVersion = versionValue
191+
if (originalVersion.endsWith('-SNAPSHOT')) {
192+
status = 'integration'
193+
thisVersion = originalVersion - 'SNAPSHOT' + getTimestamp()
194+
}
195+
else {
196+
status = 'release'
197+
thisVersion = versionValue
198+
}
199+
}
200+
201+
202+
@SuppressWarnings("UnnecessaryQualifiedReference")
203+
String getTimestamp() {
204+
// Convert local file timestamp to UTC
205+
def format = new java.text.SimpleDateFormat('yyyyMMddHHmmss')
206+
format.setCalendar(Calendar.getInstance(TimeZone.getTimeZone('UTC')));
207+
return format.format(buildTime)
208+
}
209+
210+
211+
String toString() {
212+
originalVersion
213+
}
214+
215+
216+
String getBintrayVersion() {
217+
thisVersion
218+
}
219+
220+
}

0 commit comments

Comments
 (0)