Skip to content

Commit

Permalink
Merge pull request #56 from BaristaVentures/feature/setup-buddybuild
Browse files Browse the repository at this point in the history
Setup automatic deployments
  • Loading branch information
danielgomezrico authored Dec 20, 2017
2 parents 76df8e4 + 2dd2502 commit 8333ae8
Show file tree
Hide file tree
Showing 15 changed files with 119 additions and 57 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
/build
/captures


/gradle.properties
gradle.properties
lib/bintray.properties
reporter-pivotal/bintray.properties

# Created by https://www.gitignore.io

Expand Down
8 changes: 5 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

# v 0.6.5
- Update kotlin 1.2.10
- Add missing proguard setup.
- Update third party features versions.

# v 0.6.4
- Add proguard setup.
- Update kotlin to 1.1.51.
Expand All @@ -10,19 +15,16 @@
- Remove wrong stetho-okhttp dependency.

# v 0.6.2

- Remove extra resources on PivotalTracker reporter module.
- Update dependencies.
- Simplify the use of properties view.
- Hide library resources to user.

# v 0.6.1 (~~0.6~~ BROKEN)

- Update to Kotlin 1.1.1.
- Add bug reporter with pivotal tracker, waiting others!

# v 0.5.11

- Update to Kotlin 1.0.6.
- Allow to set initial state for switch's (true/false).
- Show drawer on first launch now can be set from constructor.
Expand Down
69 changes: 49 additions & 20 deletions bintray.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
//
// This script must be applied after android app/lib plugin.
//
// Artifact id must be set in android.defaultConfig.archivesBaseName
// use -PsignPackage to allow package signing
//

/*
* Copyright 2013 Chris Banes
Expand All @@ -28,22 +25,37 @@ apply plugin: 'com.jfrog.bintray'
version = VERSION_NAME
group = GROUP

def correctSetup() {
["BINTRAY_USER",
"BINTRAY_USER_ORG",
"BINTRAY_PASSWORD",
"BINTRAY_API_KEY",
"BINTRAY_GPG_PASSPHRASE"].each {
def setup() {
println("Checking environment variables setup for ${project.name}...")
def resultOk = true

["BINTRAY_USER", "BINTRAY_USER_ORG", "BINTRAY_PASSWORD", "BINTRAY_API_KEY", "DA_OSS_USERNAME",
"DA_OSS_PWD", "DA_SIGN_SECRET_RING_FILE"].each {
if (!project.hasProperty(it)) {
println("-> bintray: $it property not found and is needed to deploy")
return false
println("-> Property '$it' not found.")
resultOk = false
}
}

if (resultOk) {
println("Relax, it's fine.\n")
} else {
println("Opps, it's incomplete.\n")
}

return resultOk
}

def getVariableOrEmpty(String name) {
if (project.hasProperty(name)) {
return project.property(name)
} else {
return ""
}
}

if (!correctSetup()) {
println("-> bintray: No bintray properties found")
if (!setup()) {
println("bintray.gradle script can't continue without all the needed variables.\n")
return
}

Expand All @@ -52,23 +64,23 @@ def isReleaseBuild() {
}

def getReleaseRepositoryUrl() {
hasProperty('RELEASE_REPOSITORY_URL') ? getProperty("RELEASE_REPOSITORY_URL") :
hasProperty('RELEASE_REPOSITORY_URL') ? getVariableOrEmpty("RELEASE_REPOSITORY_URL") :
"https://oss.sonatype.org/service/local/staging/deploy/maven2/"
}

def getSnapshotRepositoryUrl() {
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? getProperty("SNAPSHOT_REPOSITORY_URL") :
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? getVariableOrEmpty("SNAPSHOT_REPOSITORY_URL") :
"https://oss.sonatype.org/content/repositories/snapshots/"
// "https://oss.jfrog.org/artifactory/oss-snapshot-local"
// "https://oss.jfrog.org"
}

def getRepositoryUsername() {
return hasProperty('BINTRAY_USER') ? getProperty("BINTRAY_USER") : ""
return hasProperty('BINTRAY_USER') ? getVariableOrEmpty("BINTRAY_USER") : ""
}

def getRepositoryPassword() {
return hasProperty('BINTRAY_PASSWORD') ? getProperty("BINTRAY_PASSWORD") : ""
return hasProperty('BINTRAY_PASSWORD') ? getVariableOrEmpty("BINTRAY_PASSWORD") : ""
}

afterEvaluate { project ->
Expand Down Expand Up @@ -192,8 +204,13 @@ afterEvaluate { project ->
}

bintray {
user = getProperty("BINTRAY_USER")
key = getProperty("BINTRAY_API_KEY")
if (!setup()) {
println("-> bintray: No bintray properties found")
return
}

user = getVariableOrEmpty("BINTRAY_USER")
key = getVariableOrEmpty("BINTRAY_API_KEY")

configurations = ['archives']

Expand All @@ -204,7 +221,7 @@ bintray {
pkg {
repo = "maven"
name = POM_ARTIFACT_ID
userOrg = getProperty("BINTRAY_USER_ORG")
userOrg = getVariableOrEmpty("BINTRAY_USER_ORG")
desc = POM_DESCRIPTION
websiteUrl = POM_URL
issueTrackerUrl = POM_URL + '/issues'
Expand All @@ -218,6 +235,18 @@ bintray {
version {
desc = POM_DESCRIPTION
name = VERSION_NAME

gpg {
sign = false
}

mavenCentralSync {
sync = true
user = getVariableOrEmpty("DA_OSS_USERNAME")
password = getVariableOrEmpty("DA_OSS_PWD")
close = '1'
//Optional property. By default the staging repository is closed and artifacts are released to Maven Central. You can optionally turn this behaviour off (by puting 0 as value) and release the version manually.
}
}
}
}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {

dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0'
classpath plugs.kotlin
classpath plugs.gradleVersions
}
Expand Down
18 changes: 10 additions & 8 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,15 @@ machine:
dependencies:
cache_directories:
- ~/.android
- ~/android
- ~/.gradle
pre:
# Install dependencies
override:
- wget "https://services.gradle.org/distributions/$GRADLE_VERSION-bin.zip"; unzip $GRADLE_VERSION-bin.zip
- sh scripts/install-dependencies.sh

# Create config files based on all env variables
- PROPERTIES_FILE=lib/bintray.properties sh scripts/cp-env-to-properties.sh
- PROPERTIES_FILE=pivotaltracker-reporter/bintray.properties sh scripts/cp-env-to-properties.sh
- sh scripts/cp-env-to-properties.sh

test:
override:
- bash scripts/cp-env-to-properties.sh

- ./gradlew assemble -PdisablePreDex --stacktrace --no-daemon
- ./gradlew testDebugUnitTestCoverage -PdisablePreDex --stacktrace --no-daemon

Expand All @@ -35,3 +30,10 @@ test:
- cp -r lib/build/test-results $CIRCLE_TEST_REPORTS
post:
- bash <(curl -s https://codecov.io/bash) -f "$CIRCLE_TEST_REPORTS/reports/jacoco/testDebugUnitTestCoverage/testDebugUnitTestCoverage.xml"

deployment:
production:
branch: master
commands:
- bash scripts/cp-env-to-properties.sh
- bash scripts/deploy.sh
3 changes: 2 additions & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ ext {
libraries = [appCompat : "com.android.support:appcompat-v7:${versions.supportLibrary}",
supportDesign: "com.android.support:design:${versions.supportLibrary}",

kotlinStdLib : "org.jetbrains.kotlin:kotlin-stdlib:${versions.kotlin}"]
kotlinStdLib : "org.jetbrains.kotlin:kotlin-stdlib:${versions.kotlin}",
kotlinReflect: "org.jetbrains.kotlin:kotlin-reflect:${versions.kotlin}"]
}
10 changes: 3 additions & 7 deletions gradle.properties.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@ BINTRAY_USER=
BINTRAY_USER_ORG=
BINTRAY_PASSWORD=
BINTRAY_API_KEY=
BINTRAY_GPG_PASSPHRASE=

# GPG signing data
signing.keyId=
signing.password=
signing.secretKeyRingFile= # ~/.gnupg/secring.gpg
DA_OSS_USERNAME=
DA_OSS_PWD=

# Optional
ARTIST_PIVOTAL_API_KEY=
ARTIST_PIVOTAL_PROJECT_ID=
ARTIST_PIVOTAL_PROJECT_ID=
4 changes: 2 additions & 2 deletions lib/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VERSION_NAME=0.6.4
VERSION_CODE=30
VERSION_NAME=0.6.5
VERSION_CODE=31
GROUP=com.baristav.debugartist

POM_NAME=Debug Artist
Expand Down
1 change: 1 addition & 0 deletions reporter-pivotal/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ dependencies {
compile libraries.appCompat
compile libraries.supportDesign
compile libraries.kotlinStdLib
compile libraries.kotlinReflect
compile project(":lib")

compile "io.reactivex:rxjava:${versions.rxJava}"
Expand Down
4 changes: 2 additions & 2 deletions reporter-pivotal/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VERSION_NAME=0.6.4
VERSION_CODE=5
VERSION_NAME=0.6.5
VERSION_CODE=6
GROUP=com.baristav.debugartist

POM_NAME=Debug Artist - Pivotal Tracker reporter
Expand Down
7 changes: 5 additions & 2 deletions reporter-pivotal/rules.pro
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
-dontobfuscate
-keepattributes InnerClasses, EnclosingMethod
-keepattributes InnerClasses, EnclosingMethod, *Annotation*

-dontskipnonpubliclibraryclasses

-keepclasseswithmembers class debug_artist.reporter_pivotaltracker.Story { *; }
-keepclasseswithmembers class debug_artist.reporter_pivotaltracker.StoryRequestBody { *; }
-keepclasseswithmembers class debug_artist.reporter_pivotaltracker.Comment { *; }
-keepclasseswithmembers class debug_artist.reporter_pivotaltracker.Attachment { *; }
-keepclasseswithmembers class debug_artist.reporter_pivotaltracker.Attachment { *; }

-dontwarn kotlin.reflect.jvm.internal.**
15 changes: 12 additions & 3 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
apply plugin: 'com.android.application'

def getVariableOrEmpty(String name) {
if (project.hasProperty(name)) {
return project.property(name)
} else {
return ""
}
}

android {
compileSdkVersion setup.compileSdk
buildToolsVersion setup.buildTools
Expand All @@ -21,8 +29,8 @@ android {

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'rules.pro'

buildConfigField "String", "PIVOTAL_API_KEY", "\"$ARTIST_PIVOTAL_API_KEY\""
buildConfigField "String", "PIVOTAL_PROJECT_ID", "\"$ARTIST_PIVOTAL_PROJECT_ID\""
buildConfigField "String", "PIVOTAL_API_KEY", "\"${getVariableOrEmpty("DA_PIVOTAL_API_KEY")}\""
buildConfigField "String", "PIVOTAL_PROJECT_ID", "\"${getVariableOrEmpty("DA_PIVOTAL_PROJECT_ID")}\""
}
release {
minifyEnabled true
Expand All @@ -31,7 +39,8 @@ android {
}
}

signingConfigs { // Added to be able to assemble release apks with shrink
signingConfigs {
// Added to be able to assemble release apks with shrink
debug {
keyAlias "sample"
keyPassword "sample"
Expand Down
27 changes: 22 additions & 5 deletions scripts/cp-env-to-properties.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
#!/usr/bin/env bash
#
# Copy env variables to app module gradle properties file
# Prepare the project to be built from a server, creating the needed files from env variables.
#
# - Copy env variables to app module gradle properties file.
# - Decode variable names with "_BARISTA_DOT_" as ".".
# - Decode from base64 the secring.gpg
#

set +x // Hide all output

ENV_VARIABLES=$(printenv | tr ' ' '\n')
IFS=""

: ${PROPERTIES_FILE:=gradle.properties}
# Decode base64 file
echo $DA_SIGN_SECRET_RING_FILE | base64 --decode --ignore-garbage >> secring.gpg
cp secring.gpg lib/secring.gpg
cp secring.gpg reporter-pivotal/secring.gpg

set +x // dont print the next lines on run script
for PROPERTIES_FILE in gradle.properties lib/bintray.properties reporter-pivotal/bintray.properties
do
# Decode variables named like 'sign_BARISTA_DOT_password=123' to 'sign.password=123'.
# Some ci servers like circle-ci don't support env variable names with a '.'
echo ${ENV_VARIABLES//_BARISTA_DOT_/.} > $PROPERTIES_FILE

printenv | tr ' ' '\n' > $PROPERTIES_FILE
echo signing.secretKeyRingFile=secring.gpg >> $PROPERTIES_FILE
done

set -x
set -x
Empty file modified scripts/deploy.sh
100644 → 100755
Empty file.
3 changes: 2 additions & 1 deletion scripts/install-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ if [ ! -e $DEPS_FILE ]; then

touch DEPS_FILE;

fi
fi

0 comments on commit 8333ae8

Please sign in to comment.