Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
feat: Add gradle task to publish cryptobox-android on sonatype (WPB-1…
Browse files Browse the repository at this point in the history
…235) (#20)
  • Loading branch information
mythsunwind authored Jul 18, 2023
1 parent 469c066 commit 117244c
Show file tree
Hide file tree
Showing 13 changed files with 499 additions and 18 deletions.
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# Linux start script should use lf
/gradlew text eol=lf

# These are Windows script files and should use crlf
*.bat text eol=crlf

7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ bin/
gen/
libs/
obj/
build/
dist/
output/
local.properties
Expand All @@ -20,3 +19,9 @@ android/*.pom
android/*.gz
android/*.iml
android/*.properties

# Ignore Gradle project-specific cache directory
.gradle

# Ignore Gradle build output directory
build
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,4 @@ USER rust
WORKDIR /home/rust
COPY --chown=rust . cryptobox-jni
WORKDIR cryptobox-jni/android
RUN make dist || echo "FAILED TO BUILD!!"

53 changes: 53 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
pipeline {
agent {
label 'android-reloaded-builder'
}

options {
parallelsAlwaysFailFast()
disableConcurrentBuilds()
}

parameters {
string(name: 'version', defaultValue: '1.1.4')
booleanParam(name: 'deploy', defaultValue: false)
}

stages {

stage('Build') {
agent {
dockerfile true
}
steps {
checkout scm
writeFile file: 'mk/version.mk', text: "VERSION := $version"
sh "rm -rf android/dist"
sh "cd android && make dist"
stash includes: 'android/dist/*', name: 'artifacts'
archiveArtifacts artifacts: 'android/dist/*', followSymlinks: false
}
}

stage('Upload to sonatype') {
when {
expression { return params.deploy }
}
steps {
withCredentials([ usernamePassword( credentialsId: 'android-sonatype-nexus', usernameVariable: 'SONATYPE_USERNAME', passwordVariable: 'SONATYPE_PASSWORD' ),
file(credentialsId: 'D599C1AA126762B1.asc', variable: 'PGP_PRIVATE_KEY_FILE'),
string(credentialsId: 'PGP_PASSPHRASE', variable: 'PGP_PASSPHRASE') ]) {
withMaven(maven: 'M3') {
unstash 'artifacts'
sh(
script: """
touch local.properties
version=$version ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
"""
)
}
}
}
}
}
}
18 changes: 9 additions & 9 deletions android/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,28 +62,28 @@ dist/cryptobox-android-$(VERSION).tar.gz: dist-libs dist-jar doc
.PHONY: dist-tar
dist-tar: dist/cryptobox-android-$(VERSION).tar.gz

dist/cryptobox-android-$(VERSION).aar: dist-libs dist-jar
dist/cryptobox-android.aar: dist-libs dist-jar
mkdir -p dist/aar/jni
cp dist/cryptobox-jni-$(VERSION).jar dist/aar/classes.jar
cp AndroidManifest.xml dist/aar/
cp -r dist/lib/* dist/aar/jni/
cd dist/aar && zip -r ../cryptobox-android-$(VERSION).aar *
cd dist/aar && zip -r ../cryptobox-android.aar *
rm -rf dist/aar

dist/cryptobox-android-$(VERSION)-sources.jar:
jar -cvf dist/cryptobox-android-$(VERSION)-sources.jar -C ../src/java .
dist/cryptobox-android-sources.jar:
jar -cvf dist/cryptobox-android-sources.jar -C ../src/java .

dist/cryptobox-android-$(VERSION)-javadoc.jar: doc
jar -cvf dist/cryptobox-android-$(VERSION)-javadoc.jar -C dist/javadoc .
dist/cryptobox-android-javadoc.jar: doc
jar -cvf dist/cryptobox-android-javadoc.jar -C dist/javadoc .

.PHONY: dist-aar
dist-aar: dist/cryptobox-android-$(VERSION).aar
dist-aar: dist/cryptobox-android.aar

.PHONY: dist-sources
dist-sources: dist/cryptobox-android-$(VERSION)-sources.jar
dist-sources: dist/cryptobox-android-sources.jar

.PHONY: dist-javadoc
dist-javadoc: dist/cryptobox-android-$(VERSION)-javadoc.jar
dist-javadoc: dist/cryptobox-android-javadoc.jar

.PHONY: dist
dist: compile dist-tar dist-aar dist-sources dist-javadoc
Expand Down
65 changes: 65 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
plugins {
id "java-library"
id "maven-publish"
id "signing"
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
}

group = "com.wire"
version = System.getenv("version")

def Properties properties = new Properties()
properties.load(project.rootProject.file("local.properties").newDataInputStream())

nexusPublishing {
repositories {
sonatype {
username = properties.getProperty("sonatype.username") ?: System.getenv("SONATYPE_USERNAME")
password = properties.getProperty("sonatype.password") ?: System.getenv("SONATYPE_PASSWORD")
}
}
}

publishing {
publications {
mavenJava(MavenPublication) {
artifact "android/dist/cryptobox-android.aar"
artifact source: "android/dist/cryptobox-android-javadoc.jar", classifier: 'javadoc'
artifact source: "android/dist/cryptobox-android-sources.jar", classifier: 'sources'

pom {
name.set("cryptobox-android")
description.set("Wire - Cryptobox JNI bindings for Android")
url.set("https://github.com/wireapp/cryptobox-jni")
licenses {
license {
name.set("GPL-3.0")
url.set("https://opensource.org/licenses/GPL-3.0")
}
}
developers {
developer {
id.set("svenwire")
name.set("Sven Jost")
email.set("[email protected]")
organization.set("Wire Swiss GmbH")
}
}
scm {
connection.set("scm:git:git://github.com/wireapp/cryptobox-jni")
developerConnection.set("scm:git:git://github.com/wireapp/cryptobox-jni")
url.set("https://github.com/wireapp/cryptobox-jni")
}
}
}
}
}

signing {
def signingKeyFile = properties.getProperty("signingKeyFile") ?: System.getenv("PGP_PRIVATE_KEY_FILE")
def signingKey = new File(signingKeyFile).text
def signingPassword = properties.getProperty("signingPassword") ?: System.getenv("PGP_PASSPHRASE")
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.mavenJava
}

10 changes: 4 additions & 6 deletions docker-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ IMAGE_NAME="wire/cryptobox-jni"

# build
docker build -t ${IMAGE_NAME} .
docker create -ti --name temp_build ${IMAGE_NAME} bash

# archive
rm -fr output || true
rm -rf output || true
mkdir -p output
docker cp temp_build:/home/rust/cryptobox-jni/android/dist output/
echo "DONE: output is in `pwd`/output"
chmod o+rw output
docker run -v ./output:/home/rust/cryptobox-jni/android/dist ${IMAGE_NAME} make dist
echo "DONE: output is in `pwd`/output"
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 117244c

Please sign in to comment.