|
| 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() |
0 commit comments