Skip to content

Instantly share code, notes, and snippets.

@dekalo-stanislav
Created February 28, 2021 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dekalo-stanislav/773445c0c6a0081543649e1f899c8608 to your computer and use it in GitHub Desktop.
Save dekalo-stanislav/773445c0c6a0081543649e1f899c8608 to your computer and use it in GitHub Desktop.
Bintray publishing scripts set
#!/usr/bin/env bash
# https://github.com/travis-ci/travis-ci/issues/8549
# Getting current framework version
ASSERTIONS_VERSION=$(egrep -o "assertionsSdkVersion.*=.*" assertions-sdk.gradle | egrep -o "'(.*)'" | tr -d "\'")
echo "Running SDK publishing script for $ASSERTIONS_VERSION version."
### Check if it is snapshot build
if [[ $ASSERTIONS_VERSION == *"SNAPSHOT"* ]]; then
echo "[SKIP] $ASSERTIONS_VERSION is development build and should not be published."
exit 0
fi
### Checking is it already published
POM_URL="https://dl.bintray.com/dekalo-stanislav/heershingenmosiken/com/heershingenmosiken/assertions-android/$ASSERTIONS_VERSION/assertions-android-$ASSERTIONS_VERSION.pom"
if curl --output /dev/null --silent --head --fail "$POM_URL"; then
echo "[SKIP] Framework version $ASSERTIONS_VERSION already published."
exit 0
fi
### Publishing
if ./gradlew bintrayUpload bintrayPublish; then
git tag $ASSERTIONS_VERSION -a -m "$ASSERTIONS_VERSION" HEAD
git push -q origin $ASSERTIONS_VERSION
echo "[SUCCESS] $ASSERTIONS_VERSION successfully published."
else
echo "[FAILURE] Failed to publish SDK $ASSERTIONS_VERSION"
exit 1
fi
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
apply from: '../secrets.gradle'
/**
* This script is responsible for SDK publishing to maven repository.
*/
ext {
sdkGroupId = 'com.heershingenmosiken'
sdkVersion = '0.0.1'
/**
* This is list of libraries that we are going to publish.
* Also it declares mapping from local module names to public names.
*/
sdkLibNames = [
'multimodule-analytics': 'multimodule-analytics',
]
}
bintray {
user = getSecretValue('MM_ANALYTICS_BINTRAY_USER')
key = getSecretValue('MM_ANALYTICS_BINTRAY_API_KEY')
publications = ['maven']
publish = true
pkg {
repo = 'heershingenmosiken'
name = sdkLibNames[project.name]
userOrg = 'dekalo-stanislav'
vcsUrl = 'https://github.com/heershingenmosiken/multimodule-analytics'
version {
name = sdkVersion
released = new Date()
}
}
}
publishing {
publications {
maven(MavenPublication) {
groupId sdkGroupId
artifactId sdkLibNames[project.name]
version sdkVersion
pom {
name = 'Multimodule Analytics'
description = 'Library that allow easier multimodule analytics setup for Android applications'
url = 'https://github.com/heershingenmosiken/multimodule-analytics'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
withXml {
def dependenciesNode = asNode().appendNode('dependencies')
// api already included in configurations.implementation dependencies list.
configurations.implementation.allDependencies.each {
if (it.group != null && (it.name != null && "unspecified" != it.name) && (it.version != null && "unspecified" != it.version)) {
/**
* Iterate over the compile dependencies (we don't want the test ones), adding a <dependency> node for each
*/
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
} else if (sdkLibNames[it.name]) {
/**
* It is local project dependency and it is declared in sdkLibNames above.
*/
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', sdkGroupId)
dependencyNode.appendNode('artifactId', sdkLibNames[it.name])
dependencyNode.appendNode('version', sdkVersion)
}
}
}
}
}
}
repositories {
/**
* Install to local repository
*/
maven {
url System.getProperty("user.home") + "/.m2/repository"
}
}
}
/**
* Here you may define you PC local way to obtain passwords.
*/
ext {
def localPropertiesFile = project.rootProject.file('local.properties');
Properties localProperties = new Properties()
if (localPropertiesFile.exists()) {
localProperties.load(localPropertiesFile.newDataInputStream())
}
/**
* We will look required variable in local.properties, system environment and in command line properties.
*/
getSecretValue = { name ->
def result = localProperties.getProperty(name)
if (result == null) result = System.getenv(name)
if (result == null && getRootProject().hasProperty(name)) result = getRootProject().getProperty(name)
if (result == null) result = "NO_SUCH_PROPERTY"
return result
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment