Skip to content

Commit

Permalink
chore: publish artifact to maven configuration (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
gastonfournier authored Jul 18, 2024
1 parent 99fdf0a commit af4d9e2
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 7 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Publish SDK

on:
push:
tags:
- 'v*'

jobs:
deploy-release:
runs-on: ubuntu-22.04
if: startsWith(github.ref, 'refs/tags')
steps:
- uses: actions/checkout@v4
name: Checkout code
- uses: burrunan/gradle-cache-action@v1
name: Deploy Release
env:
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingPassphrase: ${{ secrets.GPG_PASSPHRASE }}
with:
job-id: release
arguments: publishToSonatype closeAndReleaseSonatypeStagingRepository
- name: Create release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
prerelease: ${{ contains(github.ref, 'beta') || contains(github.ref, 'alpha') }}
17 changes: 16 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,19 @@ plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.jetbrains.kotlin.android) apply false
alias(libs.plugins.android.library) apply false
}
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
}

val sonatypeUsername: String? by project
val sonatypePassword: String? by project

nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
username.set(sonatypeUsername)
password.set(sonatypePassword)
}
}
}
1 change: 0 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ pluginManagement {
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
Expand Down
92 changes: 89 additions & 3 deletions unleashandroidsdk/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
plugins {
`maven-publish`
signing
alias(libs.plugins.android.library)
alias(libs.plugins.jetbrains.kotlin.android)
id("org.jetbrains.dokka") version "1.7.10"
id("pl.allegro.tech.build.axion-release") version "1.13.6"
}

val tagVersion = System.getenv("GITHUB_REF")?.split('/')?.last()
project.version = scmVersion.version

android {
namespace = "io.getunleash.android"
compileSdk = 34

defaultConfig {
minSdk = 21

aarMetadata {
minCompileSdk = 29
}
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
consumerProguardFiles("proguard-rules.pro")
}

buildTypes {
debug {

}
release {
isMinifyEnabled = false
proguardFiles(
Expand All @@ -30,18 +43,26 @@ android {
kotlinOptions {
jvmTarget = "1.8"
}

publishing {
multipleVariants {
includeBuildTypeValues("debug", "release")
allVariants()
withJavadocJar()
}
}
}

dependencies {

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.androidx.work.ktx)
implementation(libs.androidx.lifecycle.process)
implementation(libs.jackson.databind)
implementation(libs.jackson.core)
implementation(libs.jackson.module.kotlin)
implementation(libs.jackson.datatype.jsr310)
implementation(libs.androidx.lifecycle.process)
api(libs.okhttp)

testImplementation(libs.junit)
Expand All @@ -58,4 +79,69 @@ dependencies {
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(libs.okhttp.mockserver)
}
}

publishing {
repositories {
repositories {
maven {
url = uri(layout.buildDirectory.dir("repo"))
name = "test"
}
}
mavenLocal()
}

publications {
afterEvaluate {
create<MavenPublication>("mavenJava") {
from(components["release"])
groupId = "io.getunleash"
artifactId = "unleash-android"
version = version
pom {
name.set("Unleash Android")
description.set("Android SDK for Unleash")
url.set("https://gh.getunleash.io/unleash-android")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("gastonfournier")
name.set("Gastón Fournier")
email.set("[email protected]")
}
developer {
id.set("chrkolst")
name.set("Christopher Kolstad")
email.set("[email protected]")
}
developer {
id.set("ivarconr")
name.set("Ivar Conradi Østhus")
email.set("[email protected]")
}
}
scm {
connection.set("scm:git:https://github.com/Unleash/unleash-android")
developerConnection.set("scm:git:ssh://[email protected]:Unleash/unleash-android")
url.set("https://github.com/Unleash/unleash-android")
}
}
}
}
}
}

val signingKey: String? by project
val signingPassphrase: String? by project
signing {
if (signingKey != null && signingPassphrase != null) {
useInMemoryPgpKeys(signingKey, signingPassphrase)
sign(publishing.publications["mavenJava"])
}
}
4 changes: 3 additions & 1 deletion unleashandroidsdk/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile
-keep public class io.getunleash.** { *; }
-keep class com.fasterxml.** { *; }
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class DefaultUnleashTest: BaseTest() {
})
unleash.start()

await().atMost(1, TimeUnit.SECONDS).until { ready }
await().atMost(2, TimeUnit.SECONDS).until { ready }
val variant = unleash.getVariant("AwesomeDemo")
assertThat(variant).isNotNull
assertThat(variant.enabled).isTrue()
Expand Down

0 comments on commit af4d9e2

Please sign in to comment.