Skip to content

Commit 512e207

Browse files
Final tools for creating and deploying artifacts (#275)
Can deploy artifacts to leanplum repo
1 parent b67a632 commit 512e207

File tree

8 files changed

+133
-14
lines changed

8 files changed

+133
-14
lines changed

AndroidSDKCore/build.gradle

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@ android {
1515
consumerProguardFiles CONSUMER_PROGUARD_FILES
1616

1717
def packageIdentifier = System.getenv('LEANPLUM_PACKAGE_IDENTIFIER') ?: 's'
18-
buildConfigField 'String', 'LEANPLUM_PACKAGE_IDENTIFIER', '\"' + packageIdentifier + '\"'
18+
buildConfigField 'String', 'LEANPLUM_PACKAGE_IDENTIFIER', "\"${packageIdentifier}\""
1919

20-
def sdkVersion = file('sdk-version.txt').text
21-
buildConfigField 'String', 'SDK_VERSION', '\"' + sdkVersion + '\"'
20+
buildConfigField 'String', 'SDK_VERSION', "\"${LEANPLUM_SDK_VERSION}\""
2221

2322
def buildNumber = System.getenv('BUILD_NUMBER') ?: '0'
24-
buildConfigField 'String', 'BUILD_NUMBER', '\"' + buildNumber + '\"'
23+
buildConfigField 'String', 'BUILD_NUMBER', "\"${buildNumber}\""
2524
}
2625
buildTypes {
2726
release {
@@ -47,4 +46,4 @@ task generateJavadoc(type: Javadoc) {
4746
failOnError false
4847
}
4948

50-
publishing_task(LEANPLUM_CORE_ARTIFACT_ID, 'AndroidSDKCore')
49+
publishing_task(LEANPLUM_CORE_ARTIFACT_ID, 'AndroidSDKCore')

Makefile

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
SDK_BUILD_IMAGE:=leanplum/android-sdk-build:latest
88
DOCKER_RUN:=docker run \
99
--tty --interactive --rm \
10-
--volume `pwd`:/leanplum \
11-
--workdir /leanplum \
10+
--volume `pwd`/..:/leanplum \
11+
--env JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 \
12+
--env DEBUG=1 \
13+
--workdir /leanplum/Leanplum-Android-SDK \
1214
${SDK_BUILD_IMAGE}
1315

1416
clean-local-properties:
@@ -27,4 +29,16 @@ shell:
2729
build-image:
2830
docker build -t ${SDK_BUILD_IMAGE} . -f Tools/jenkins/build.dockerfile
2931

30-
.PHONY: build
32+
patchReleaseBranch:
33+
./Tools/create-release.bash patch
34+
35+
releaseArtifacts: releaseBinaries releasePoms
36+
37+
releaseBinaries:
38+
${DOCKER_RUN} gradle assembleRelease --debug
39+
40+
releasePoms:
41+
${DOCKER_RUN} gradle generatePomFileForAarPublication --debug
42+
43+
deploy:
44+
./Tools/deploy.py

Tools/create-release.bash

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ set -o errexit
1111
TYPE=$1
1212

1313
release_version=$(./Tools/create-release.py ${TYPE})
14-
cat AndroidSDKCore/sdk-version.txt
14+
cat sdk-version.txt
1515

1616
git reset HEAD --
1717
RELEASE_BRANCH=release/${release_version}
1818
git checkout -b ${RELEASE_BRANCH}
1919

20-
git add AndroidSDKCore/sdk-version.txt
20+
git add sdk-version.txt
2121
git commit -m "Create ${TYPE} release ${release_version}"
22-
git push --set-upstream origin ${RELEASE_BRANCH}
22+
23+
echo "Branch created but not pushed."

Tools/create-release.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
import semver
44
import sys
55

6-
SDK_VERSION_FILE = "AndroidSDKCore/sdk-version.txt"
6+
SDK_VERSION_FILE = "sdk-version.txt"
77

88
def get_current_version():
99
with open(SDK_VERSION_FILE, 'r') as f:
10-
return f.read()
10+
return f.read().strip()
1111

1212
def update_version(version):
1313
with open(SDK_VERSION_FILE, 'w') as f:

Tools/deploy.py

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#!/usr/bin/env python2.7
2+
3+
import os
4+
5+
SDK_VERSION_FILE = "sdk-version.txt"
6+
7+
8+
def get_current_version():
9+
with open(SDK_VERSION_FILE, 'r') as f:
10+
return f.read().strip()
11+
12+
VERSION = get_current_version()
13+
14+
15+
class Artifact:
16+
17+
def __init__(self, path, extension):
18+
self.path = path
19+
self.extension = extension
20+
21+
22+
class Package:
23+
24+
def __init__(self, project, package):
25+
self.project = project
26+
self.package = package
27+
self.artifacts = [
28+
Artifact(
29+
"/build/intermediates/packaged-classes/release/classes.jar", "jar"),
30+
Artifact(
31+
"/build/publications/aar/pom-default.xml", "pom"),
32+
Artifact("/build/outputs/aar/" +
33+
project + "-release.aar", "aar"),
34+
]
35+
36+
def validate(self):
37+
paths = [artifact.path for artifact in self.artifacts]
38+
valid = True
39+
for path in paths:
40+
filePath = self.project + path
41+
if not os.path.isfile(filePath):
42+
valid = False
43+
print "Critical artifact missing: " + filePath
44+
45+
if not valid:
46+
system.exit(1)
47+
48+
def deploy(self):
49+
self.validate()
50+
51+
for artifact in self.artifacts:
52+
self.deployArtifact(artifact.path, artifact.extension)
53+
54+
def deployArtifact(self, localPath, extension):
55+
location = self.project + localPath
56+
remotePathBase = self.remotePath(extension)
57+
artifactoryPath = "libs-release-local/" + remotePathBase
58+
bintrayPath = "https://api.bintray.com/content/leanplum/maven/" + \
59+
self.package + "/" + remotePathBase
60+
deployArtifacts(location, artifactoryPath, bintrayPath)
61+
62+
def remotePath(self, extension):
63+
path = "com/leanplum/" + self.package + "/" + VERSION + \
64+
"/" + self.remoteFilename(extension)
65+
return path
66+
67+
def remoteFilename(self, extension):
68+
return self.package + "-" + VERSION + "." + extension
69+
70+
71+
def deployArtifacts(localPath, artifactoryPath, bintrayPath):
72+
artifactoryDeploy(localPath, artifactoryPath)
73+
bintrayDeploy(localPath, bintrayPath)
74+
75+
76+
def artifactoryDeploy(source, destination):
77+
command = "jfrog rt u " + source + " " + destination
78+
# print command
79+
os.system(command)
80+
81+
82+
def bintrayDeploy(source, destination):
83+
command = "curl -T " + source + " -ue7mac:" + "API_KEY " + destination
84+
# print command
85+
# os.system(command)
86+
87+
88+
packages = [
89+
Package("AndroidSDKCore", "leanplum-core"),
90+
Package("AndroidSDKPush", "leanplum-push"),
91+
Package("AndroidSDKGcm", "leanplum-gcm"),
92+
Package("AndroidSDKFcm", "leanplum-fcm"),
93+
Package("AndroidSDKLocation", "leanplum-location"),
94+
]
95+
96+
97+
def main():
98+
for package in packages:
99+
package.deploy()
100+
101+
if __name__ == "__main__":
102+
main()

Tools/jenkins/build.dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,7 @@ ENV PATH="$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$ANDROID_HOME/t
3232
RUN sdkmanager emulator tools platform-tools ${platform_image} ${system_image} --verbose && \
3333
echo no | avdmanager create avd -n "device1" --package ${system_image} --tag google_apis
3434

35+
ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
36+
3537
################################
3638
CMD ["bash"]

common-methods.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ ext {
1111
LEANPLUM_FCM_ARTIFACT_ID = 'leanplum-fcm'
1212
LEANPLUM_GCM_ARTIFACT_ID = 'leanplum-gcm'
1313
LEANPLUM_LOCATION_ARTIFACT_ID = 'leanplum-location'
14-
LEANPLUM_SDK_VERSION = "$System.env.ANDROID_VERSION_STRING"
14+
def sdkVersion = file('../sdk-version.txt').text
15+
LEANPLUM_SDK_VERSION = "$sdkVersion"
1516

1617
PROGUARD_FILES = 'proguard-rules.pro'
1718
CONSUMER_PROGUARD_FILES = 'consumer-proguard-rules.pro'
File renamed without changes.

0 commit comments

Comments
 (0)