Skip to content

Commit 6c2e133

Browse files
authored
Publish to S3 instead of Bintray (#63)
2 parents 24420c1 + ba4eecc commit 6c2e133

File tree

4 files changed

+34
-128
lines changed

4 files changed

+34
-128
lines changed

.circleci/config.yml

Lines changed: 15 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: 2.1
22

33
orbs:
4-
android: wordpress-mobile/android@0.0.22
4+
android: wordpress-mobile/android@1.0.20
55

66
commands:
77
copy-gradle-properties:
@@ -36,77 +36,31 @@ jobs:
3636
name: Test
3737
command: ./gradlew --stacktrace test
3838
- android/save-gradle-cache
39-
Build and upload to Bintray:
39+
Build and upload to S3:
4040
executor:
4141
name: android/default
4242
api-version: "27"
4343
steps:
44+
- android/check-precondition-for-publish-artifacts
4445
- checkout
4546
- copy-gradle-properties
4647
- android/restore-gradle-cache
47-
- run:
48-
name: Bintray Upload
49-
command: |
50-
# Use a different versioning style for builds from PRs to allow
51-
# developers to iterate faster.
52-
#
53-
# All those dev builds will be deleted once the PR is merged by
54-
# https://github.com/Automattic/bintray-garbage-collector/
55-
#
56-
# If $PREFIX is not set, that is, if we're not on a PR but a merge
57-
# commit on develop or trunk, the version will be the value from
58-
# the source code.
59-
branch=$CIRCLE_BRANCH
60-
if [[ -n "$CIRCLE_PULL_REQUEST" ]]; then
61-
PR_NUMBER=$(basename $CIRCLE_PULL_REQUEST)
62-
# Making the assumption that $CIRCLE_SHA1 will always be
63-
# available.
64-
PREFIX="$PR_NUMBER-$CIRCLE_SHA1"
65-
elif [[ "$branch" != "trunk" && "$branch" != "develop" ]]; then
66-
# This happens on the first push of a new branch, when there
67-
# isn't a PR open for it yet.
68-
echo "Running on a feature branch with no open PR: skipping Bintray upload"
69-
exit 0
70-
fi
71-
72-
# Locally, calling `./gradlew bintrayUpload` is enough to generate
73-
# all the required artifacts. On CI, unless run each task
74-
# individually, the Bintray task will fail to find the AAR and
75-
# POM artifacts in the build/ folder.
76-
#
77-
# This builds the AAR.
78-
./gradlew --stacktrace assembleRelease
79-
80-
# This builds the POM.
81-
#
82-
# On local, the POM is generated automatically as part of
83-
# assembleRelease, but that doesn't seem to be the case on CI. Here
84-
# we need to explicitly generated it, otherwise bintrayUpload won't
85-
# find it and won't upload it.
86-
#
87-
# Worth noting that the Bintray plugin mentions the necessity for
88-
# some workarounds to generate the POM under certain circumstances,
89-
# although none of them apply to our current usage. See:
90-
# https://github.com/bintray/gradle-bintray-plugin/tree/67718c3a65b64dbfe7534a82a178da2c57153a5d#maven-publications
91-
#
92-
# See also the description and comments in this PR:
93-
# https://github.com/wordpress-mobile/WordPress-Utils-Android/pull/39
94-
#
95-
# Notice the `-PbintrayVersion` parameter to make sure the POM has
96-
# the same version as the one bintrayUpload will use.
97-
./gradlew --stacktrace generatePomFileForUtilsPublicationPublication -PbintrayVersion=$PREFIX
98-
99-
# Finally, this uploads both AAR and POM to Bintray.
100-
./gradlew --stacktrace bintrayUpload -PbintrayVersion=$PREFIX
48+
- android/publish-to-s3:
49+
module_name: WordPressUtils
10150
- android/save-gradle-cache
10251

10352
workflows:
104-
# We don't want this to run on tags, but no filter statement is necessary
105-
# because that's the default behavior
10653
WordPress-Utils-Android:
10754
jobs:
10855
- Lint
109-
- Test
110-
- Build and upload to Bintray:
56+
- Test:
57+
filters:
58+
tags:
59+
only: /.*/
60+
- Build and upload to S3:
11161
requires:
112-
- Test
62+
- Test
63+
filters:
64+
tags:
65+
only: /.*/
66+

README.md

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,25 @@ Collection of utility methods for Android and WordPress.
44

55
## Use the library in your project
66

7-
* In your build.gradle:
7+
* In your `build.gradle`:
88
```groovy
9-
dependencies {
10-
compile 'org.wordpress:utils:1.30.0' // use version 1.30.0
9+
repositories {
10+
maven { url "https://a8c-libs.s3.amazonaws.com/android" }
1111
}
12-
```
13-
14-
## Publish an updated version to your local maven repository
15-
16-
You can bump the [version name in the main build file: `WordPressUtils/build.gradle`][1]. After updating the build file, you can build, and publish the library to your local maven repo. That will let you try the new version in your app for example.
1712
18-
```shell
19-
$ ./gradlew assemble test publishToMavenLocal
13+
dependencies {
14+
implementation 'org.wordpress:utils:1.31.0'
15+
}
2016
```
2117

22-
## Publish it to Bintray
18+
## Publishing a new version
2319

24-
When a new version is ready to be published to the remote repository, use the following command to publish it to Bintray:
20+
In the following cases, CircleCI will publish a new version with the following format to our remote Maven repo:
2521

26-
```shell
27-
$ ./gradlew clean build
28-
$ ./gradlew bintrayUpload -PbintrayUser=FIXME -PbintrayKey=FIXME
29-
```
22+
* For each commit in an open PR: `<PR-number>-<commit full SHA1>`
23+
* Each time a PR is merged to `develop`: `develop-<commit full SHA1>`
24+
* Each time a PR is merged to `trunk`: `trunk-<commit full SHA1>`
25+
* Each time a new tag is created: `{tag-name}`
3026

3127
## Apps and libraries using WordPress-Utils-Android:
3228

WordPressUtils/build.gradle

Lines changed: 7 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ buildscript {
55
repositories {
66
google()
77
jcenter()
8+
maven { url 'https://a8c-libs.s3.amazonaws.com/android' }
89
}
910
dependencies {
1011
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
1112
classpath 'com.android.tools.build:gradle:4.0.1'
12-
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5'
13+
classpath 'com.automattic.android:publish-to-s3:0.2.2'
1314
}
1415
}
1516

1617
apply plugin: 'com.android.library'
1718
apply plugin: 'kotlin-android'
1819
apply plugin: 'kotlin-android-extensions'
19-
apply plugin: 'maven-publish'
20-
apply plugin: 'com.jfrog.bintray'
20+
apply plugin: 'com.automattic.android.publish-to-s3'
2121

2222
repositories {
2323
google()
@@ -88,47 +88,9 @@ android.libraryVariants.all { variant ->
8888
}
8989
}
9090

91-
// Allows to override the artifact version by passing a -PbintrayVersion
92-
// parameter when calling Gradle
93-
def getBintrayVersion() {
94-
return project.properties['bintrayVersion'] ?: android.defaultConfig.versionName
95-
}
96-
97-
bintray {
98-
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
99-
key = project.hasProperty('bintrayKey') ? project.property('bintrayKey') : System.getenv('BINTRAY_KEY')
100-
publications = ['UtilsPublication']
101-
publish = true
102-
pkg {
103-
repo = 'maven'
104-
name = 'utils'
105-
userOrg = 'wordpress-mobile'
106-
licenses = ['MIT', 'GPL']
107-
vcsUrl = 'https://github.com/wordpress-mobile/WordPress-Utils-Android.git'
108-
version {
109-
name = getBintrayVersion()
110-
desc = 'Utils library for Android'
111-
released = new Date()
112-
}
113-
}
114-
}
115-
116-
// Because the components are created only during the `afterEvaluate` phase, we
117-
// must configure our publications using the `afterEvaluate()` lifecycle method
118-
//
119-
// See https://developer.android.com/studio/build/maven-publish-plugin
120-
project.afterEvaluate {
121-
publishing {
122-
publications {
123-
UtilsPublication(MavenPublication) {
124-
// Applies the component for the release build variant
125-
from components.release
126-
127-
groupId 'org.wordpress'
128-
artifactId 'utils'
129-
version getBintrayVersion()
130-
}
131-
}
132-
}
91+
s3PublishPlugin {
92+
groupId "org.wordpress"
93+
artifactId "utils"
94+
from "release"
13395
}
13496

build.gradle

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,4 @@ allprojects {
3232
configFile file("${project.rootDir}/config/checkstyle.xml")
3333
}
3434
}
35-
36-
// Suppress false Javadoc lint errors preventing Bintray release
37-
// See https://stackoverflow.com/questions/34828426/disable-javadoc-check-for-bintray-upload
38-
tasks.withType(Javadoc) {
39-
options.addBooleanOption('Xdoclint:none', true)
40-
}
4135
}

0 commit comments

Comments
 (0)