Skip to content

Commit

Permalink
Merge pull request wordpress-mobile#2083 from wordpress-mobile/publis…
Browse files Browse the repository at this point in the history
…h-to-s3

Publish to s3
  • Loading branch information
oguzkocer authored Aug 4, 2021
2 parents 5a94ad8 + 5f81375 commit 0193e64
Show file tree
Hide file tree
Showing 11 changed files with 217 additions and 18 deletions.
48 changes: 48 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
common-params:
&publish-android-artifacts-docker-container
docker#v3.8.0:
image: "public.ecr.aws/automattic/android-build-image:v1.1.0"
propagate-environment: true
environment:
# DO NOT MANUALLY SET THESE VALUES!
# They are passed from the Buildkite agent to the Docker container
- "AWS_ACCESS_KEY"
- "AWS_SECRET_KEY"

steps:
- label: "Publish :fluxc-annotations"
key: "publish-fluxc-annotations"
plugins:
- *publish-android-artifacts-docker-container
command: |
.buildkite/publish-fluxc-annotations.sh
- label: "Publish :fluxc-processor"
key: "publish-fluxc-processor"
depends_on:
- "publish-fluxc-annotations"
plugins:
- *publish-android-artifacts-docker-container
command: |
.buildkite/publish-fluxc-processor.sh
- label: "Publish :fluxc"
key: "publish-fluxc"
depends_on:
- "publish-fluxc-processor"
- "publish-fluxc-annotations"
plugins:
- *publish-android-artifacts-docker-container
command: |
.buildkite/publish-fluxc.sh
- label: "Publish :plugins:woocommerce"
key: "publish-plugins-woocommerce"
depends_on:
- "publish-fluxc-processor"
- "publish-fluxc-annotations"
- "publish-fluxc"
plugins:
- *publish-android-artifacts-docker-container
command: |
.buildkite/publish-plugins-woocommerce.sh
10 changes: 10 additions & 0 deletions .buildkite/publish-fluxc-annotations.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -euo pipefail

./gradlew \
:fluxc-annotations:prepareToPublishToS3 $(prepare_to_publish_to_s3_params) \
:fluxc-annotations:publish

# Add meta-data for the published version so we can use it in subsequent steps
cat ./fluxc-annotations/build/published-version.txt | buildkite-agent meta-data set "PUBLISHED_FLUXC_ANNOTATIONS_VERSION"
14 changes: 14 additions & 0 deletions .buildkite/publish-fluxc-processor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -euo pipefail

# Retrieve data from previous steps
PUBLISHED_FLUXC_ANNOTATIONS_VERSION=$(buildkite-agent meta-data get "PUBLISHED_FLUXC_ANNOTATIONS_VERSION")

./gradlew \
-PfluxcAnnotationsVersion="$PUBLISHED_FLUXC_ANNOTATIONS_VERSION" \
:fluxc-processor:prepareToPublishToS3 $(prepare_to_publish_to_s3_params) \
:fluxc-processor:publish

# Add meta-data for the published version so we can use it in subsequent steps
cat ./fluxc-processor/build/published-version.txt | buildkite-agent meta-data set "PUBLISHED_FLUXC_PROCESSOR_VERSION"
17 changes: 17 additions & 0 deletions .buildkite/publish-fluxc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

set -euo pipefail

# Retrieve data from previous steps
PUBLISHED_FLUXC_ANNOTATIONS_VERSION=$(buildkite-agent meta-data get "PUBLISHED_FLUXC_ANNOTATIONS_VERSION")
PUBLISHED_FLUXC_PROCESSOR_VERSION=$(buildkite-agent meta-data get "PUBLISHED_FLUXC_PROCESSOR_VERSION")

cp gradle.properties-example gradle.properties
./gradlew \
-PfluxcAnnotationsVersion="$PUBLISHED_FLUXC_ANNOTATIONS_VERSION" \
-PfluxcProcessorVersion="$PUBLISHED_FLUXC_PROCESSOR_VERSION" \
:fluxc:prepareToPublishToS3 $(prepare_to_publish_to_s3_params) \
:fluxc:publish

# Add meta-data for the published version so we can use it in subsequent steps
cat ./fluxc/build/published-version.txt | buildkite-agent meta-data set "PUBLISHED_FLUXC_VERSION"
16 changes: 16 additions & 0 deletions .buildkite/publish-plugins-woocommerce.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -euo pipefail

# Retrieve data from previous steps
PUBLISHED_FLUXC_ANNOTATIONS_VERSION=$(buildkite-agent meta-data get "PUBLISHED_FLUXC_ANNOTATIONS_VERSION")
PUBLISHED_FLUXC_PROCESSOR_VERSION=$(buildkite-agent meta-data get "PUBLISHED_FLUXC_PROCESSOR_VERSION")
PUBLISHED_FLUXC_VERSION=$(buildkite-agent meta-data get "PUBLISHED_FLUXC_VERSION")

cp gradle.properties-example gradle.properties
./gradlew \
-PfluxcAnnotationsVersion="$PUBLISHED_FLUXC_ANNOTATIONS_VERSION" \
-PfluxcProcessorVersion="$PUBLISHED_FLUXC_PROCESSOR_VERSION" \
-PfluxcVersion="$PUBLISHED_FLUXC_VERSION" \
:plugins:woocommerce:prepareToPublishToS3 $(prepare_to_publish_to_s3_params) \
:plugins:woocommerce:publish
11 changes: 11 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ allprojects {
apply plugin: 'checkstyle'

repositories {
maven {
url "https://a8c-libs.s3.amazonaws.com/android"
content {
includeGroup "org.wordpress"
includeGroup "org.wordpress.fluxc"
}
}
google()
jcenter()
mavenCentral()
Expand Down Expand Up @@ -66,4 +73,8 @@ ext {
assertJVersion = '3.19.0'
kotlinCoroutinesVersion = '1.3.9'
roomVersion = "2.3.0"

fluxcAnnotationsProjectDependency = project.hasProperty("fluxcAnnotationsVersion") ? "org.wordpress.fluxc:fluxc-annotations:${project.getProperty("fluxcAnnotationsVersion")}" : project(":fluxc-annotations")
fluxcProcessorProjectDependency = project.hasProperty("fluxcProcessorVersion") ? "org.wordpress.fluxc:fluxc-processor:${project.getProperty("fluxcProcessorVersion")}" : project(":fluxc-processor")
fluxcProjectDependency = project.hasProperty("fluxcVersion") ? "org.wordpress:fluxc:${project.getProperty("fluxcVersion")}" : project(":fluxc")
}
25 changes: 23 additions & 2 deletions fluxc-annotations/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
apply plugin: 'maven'
apply plugin: 'java'
plugins {
id "java"
id "com.automattic.android.publish-to-s3"
}

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

project.afterEvaluate {
publishing {
publications {
FluxCAnnotationsPublication(MavenPublication) {
from components.java

groupId "org.wordpress.fluxc"
artifactId "fluxc-annotations"
// version is set by 'publish-to-s3' plugin
}
}
}
}

publishToS3Plugin {
mavenPublishGroupId "org.wordpress.fluxc"
mavenPublishArtifactId "fluxc-annotations"
}
23 changes: 21 additions & 2 deletions fluxc-processor/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,35 @@
plugins {
id "java"
id "maven"
id "org.jetbrains.kotlin.jvm"
id "org.jetbrains.kotlin.kapt"
id "com.automattic.android.publish-to-s3"
}

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

dependencies {
implementation project (':fluxc-annotations')
implementation fluxcAnnotationsProjectDependency
implementation 'com.google.auto.service:auto-service:1.0-rc4'
kapt 'com.google.auto.service:auto-service:1.0-rc4'
implementation 'com.squareup:javapoet:1.7.0'
}

project.afterEvaluate {
publishing {
publications {
FluxCProcessorPublication(MavenPublication) {
from components.java

groupId "org.wordpress.fluxc"
artifactId "fluxc-processor"
// version is set by 'publish-to-s3' plugin
}
}
}
}

publishToS3Plugin {
mavenPublishGroupId "org.wordpress.fluxc"
mavenPublishArtifactId "fluxc-processor"
}
28 changes: 21 additions & 7 deletions fluxc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
id "org.jetbrains.kotlin.android"
id "org.jetbrains.kotlin.android.extensions"
id "org.jetbrains.kotlin.kapt"
id "com.github.dcendents.android-maven"
id "com.automattic.android.publish-to-s3"
}

android {
Expand All @@ -12,8 +12,6 @@ android {
compileSdkVersion 29

defaultConfig {
versionCode 4
versionName "0.1"
minSdkVersion 18
targetSdkVersion 29
javaCompileOptions {
Expand Down Expand Up @@ -76,8 +74,8 @@ dependencies {
kapt "org.wordpress:wellsql-processor:$wellSqlVersion"

// FluxC annotations
api project(':fluxc-annotations')
kapt project(':fluxc-processor')
api fluxcAnnotationsProjectDependency
kapt fluxcProcessorProjectDependency

// External libs
api 'org.greenrobot:eventbus:3.2.0'
Expand Down Expand Up @@ -105,5 +103,21 @@ dependencies {
api "net.java.dev.jna:jna:5.5.0@aar"
}

version = android.defaultConfig.versionName
group = "org.wordpress"
project.afterEvaluate {
publishing {
publications {
FluxCPublication(MavenPublication) {
from components.release

groupId "org.wordpress"
artifactId "fluxc"
// version is set by 'publish-to-s3' plugin
}
}
}
}

publishToS3Plugin {
mavenPublishGroupId "org.wordpress"
mavenPublishArtifactId "fluxc"
}
29 changes: 22 additions & 7 deletions plugins/woocommerce/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ plugins {
id "com.android.library"
id "org.jetbrains.kotlin.android"
id "org.jetbrains.kotlin.kapt"
id "com.github.dcendents.android-maven"
id "com.automattic.android.publish-to-s3"
}

android {
compileSdkVersion 29

defaultConfig {
versionCode 1
versionName "0.1"
minSdkVersion 18
targetSdkVersion 29
}
Expand All @@ -27,7 +25,7 @@ android {
}

dependencies {
implementation project(':fluxc')
implementation fluxcProjectDependency

implementation 'org.apache.commons:commons-lang3:3.7'

Expand All @@ -42,8 +40,8 @@ dependencies {
kapt "org.wordpress:wellsql-processor:$wellSqlVersion"

// FluxC annotations
api project(':fluxc-annotations')
kapt project(':fluxc-processor')
api fluxcAnnotationsProjectDependency
kapt fluxcProcessorProjectDependency

implementation 'com.google.code.gson:gson:2.8.0'

Expand All @@ -57,4 +55,21 @@ dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinCoroutinesVersion"
}

group 'org.wordpress'
project.afterEvaluate {
publishing {
publications {
PluginWoocommercePublication(MavenPublication) {
from components.release

groupId "org.wordpress.fluxc.plugins"
artifactId "woocommerce"
// version is set by 'publish-to-s3' plugin
}
}
}
}

publishToS3Plugin {
mavenPublishGroupId "org.wordpress.fluxc.plugins"
mavenPublishArtifactId "woocommerce"
}
14 changes: 14 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ pluginManagement {
id "org.jetbrains.kotlin.android.extensions" version gradle.ext.kotlinVersion
id "org.jetbrains.kotlin.jvm" version gradle.ext.kotlinVersion
id "org.jetbrains.kotlin.kapt" version gradle.ext.kotlinVersion
id "com.automattic.android.publish-to-s3" version "0.6.1"
}
repositories {
maven {
url 'https://a8c-libs.s3.amazonaws.com/android'
content {
includeGroup "com.automattic.android"
includeGroup "com.automattic.android.publish-to-s3"
}
}
gradlePluginPortal()
Expand Down Expand Up @@ -44,3 +46,15 @@ include ':fluxc',
':example',
':instaflux',
':tests:api'

// Build cache is only enabled for CI, at least for now
if (System.getenv().containsKey("CI")) {
buildCache {
remote(HttpBuildCache) {
url = "http://10.0.2.215:5071/cache/"
allowUntrustedServer = true
allowInsecureProtocol = true
push = true
}
}
}

0 comments on commit 0193e64

Please sign in to comment.