Skip to content

Commit 9629007

Browse files
authored
ci: Deploying to Maven central (#50)
Signed-off-by: Nicklas Lundin <[email protected]>
1 parent c66558a commit 9629007

File tree

3 files changed

+105
-41
lines changed

3 files changed

+105
-41
lines changed

.github/workflows/release_please.yaml

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,8 @@ jobs:
2424
run: |
2525
echo "$RELEASE_PLEASE_OUTPUT"
2626
27-
# Outputs are namespaced by package when using a manifest in Release Please
2827
outputs:
29-
release_created: ${{ steps.release.outputs['OpenFeature--release_created'] }}
30-
# Version doesn't include `v` as a prefix. This is undocumented
31-
version: ${{ steps.release.outputs['OpenFeature--version'] }}
32-
upload_url: ${{ steps.release.outputs['OpenFeature--upload_url'] }}
28+
release_created: ${{ steps.release.outputs.release_created }}
3329

3430
kotlin-release:
3531
needs: release-please
@@ -49,23 +45,37 @@ jobs:
4945
5046
- uses: actions/checkout@v4
5147

48+
- name: Configure GPG Key
49+
run: |
50+
echo -n "$GPG_SIGNING_KEY" | gpg --import
51+
gpg --pinentry-mode=loopback --export-secret-key 08C5EC5C > ~/.gnupg/secring.gpg
52+
env:
53+
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
54+
55+
- name: Add signing secrets to gradle.properties
56+
run: |
57+
mkdir -p ~/.gradle/
58+
echo "signing.keyId=08C5EC5C" >> ~/.gradle/gradle.properties
59+
echo "signing.secretKeyRingFile=/home/runner/.gnupg/secring.gpg" >> ~/.gradle/gradle.properties
60+
echo "signing.password=$GPG_SIGNING_KEY_PASSWORD" >> ~/.gradle/gradle.properties
61+
env:
62+
GPG_SIGNING_KEY_ID: ${{ secrets.GPG_SIGNING_KEY_ID }}
63+
GPG_SIGNING_KEY_PASSWORD: ${{ secrets.GPG_SIGNING_KEY_PASSWORD }}
64+
5265
- name: Set up JDK 11
5366
uses: actions/setup-java@v3
5467
with:
5568
java-version: 11
69+
distribution: 'zulu'
5670

5771
- name: Grant Permission for Gradlew to Execute
5872
run: chmod +x gradlew
5973

60-
- name: Build AAR ⚙️🛠
61-
run: bash ./gradlew :openfeature:assemble
62-
63-
- name: Upload Openfeature SDK AAR 🗳
64-
uses: actions/upload-release-asset@v1
74+
- name: Publish to Sonatype
6575
env:
66-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67-
with:
68-
upload_url: ${{ needs.release-please.outputs.upload_url }}
69-
asset_path: OpenFeature/build/outputs/aar/OpenFeature-release.aar
70-
asset_name: openfeature-sdk.aar
71-
asset_content_type: application/aar
76+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
77+
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
78+
run: ./gradlew publishToSonatype closeSonatypeStagingRepository --no-daemon --stacktrace
79+
80+
- name: Clean up signing secrets
81+
run: rm ~/.gradle/gradle.properties

OpenFeature/build.gradle.kts

Lines changed: 67 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ plugins {
33
id("com.android.library")
44
id("org.jetbrains.kotlin.android")
55
id("maven-publish")
6+
id("signing")
67
id("org.jlleitschuh.gradle.ktlint")
78
kotlin("plugin.serialization") version "1.9.10"
89
}
@@ -38,41 +39,82 @@ android {
3839
kotlinOptions {
3940
jvmTarget = JavaVersion.VERSION_11.toString()
4041
}
41-
}
42-
43-
dependencies {
44-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
45-
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0")
46-
testImplementation("junit:junit:4.13.2")
47-
testImplementation("org.mockito.kotlin:mockito-kotlin:5.1.0")
48-
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3")
49-
}
5042

51-
afterEvaluate {
5243
publishing {
53-
publications {
54-
register<MavenPublication>("release") {
55-
groupId = "dev.openfeature"
56-
artifactId = "kotlin-sdk"
57-
version = releaseVersion
44+
singleVariant("release") {
45+
withJavadocJar()
46+
withSourcesJar()
47+
}
48+
}
49+
}
5850

59-
from(components["release"])
60-
artifact(androidSourcesJar.get())
51+
publishing {
52+
publications {
53+
register<MavenPublication>("release") {
54+
groupId = "dev.openfeature"
55+
artifactId = "kotlin-sdk"
56+
version = releaseVersion
6157

62-
pom {
63-
name.set("OpenfeatureSDK")
58+
pom {
59+
name.set("OpenFeature Android SDK")
60+
description.set(
61+
"This is the Android implementation of OpenFeature, a vendor-agnostic abstraction library for evaluating feature flags."
62+
)
63+
url.set("https://openfeature.dev")
64+
licenses {
65+
license {
66+
name.set("The Apache License, Version 2.0")
67+
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
68+
}
69+
}
70+
developers {
71+
developer {
72+
id.set("vahidlazio")
73+
name.set("Vahid Torkaman")
74+
email.set("[email protected]")
75+
}
76+
developer {
77+
id.set("fabriziodemaria")
78+
name.set("Fabrizio Demaria")
79+
email.set("[email protected]")
80+
}
81+
developer {
82+
id.set("nicklasl")
83+
name.set("Nicklas Lundin")
84+
email.set("[email protected]")
85+
}
86+
developer {
87+
id.set("nickybondarenko")
88+
name.set("Nicky Bondarenko")
89+
email.set("[email protected]")
90+
}
91+
}
92+
scm {
93+
connection.set(
94+
"scm:git:https://github.com/open-feature/kotlin-sdk.git"
95+
)
96+
developerConnection.set(
97+
"scm:git:ssh://open-feature/kotlin-sdk.git"
98+
)
99+
url.set("https://github.com/open-feature/kotlin-sdk")
64100
}
65101
}
102+
103+
afterEvaluate {
104+
from(components["release"])
105+
}
66106
}
67107
}
68108
}
69109

70-
val androidSourcesJar by tasks.registering(Jar::class) {
71-
archiveClassifier.set("sources")
72-
from(android.sourceSets.getByName("main").java.srcDirs)
110+
dependencies {
111+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
112+
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0")
113+
testImplementation("junit:junit:4.13.2")
114+
testImplementation("org.mockito.kotlin:mockito-kotlin:5.1.0")
115+
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3")
73116
}
74117

75-
// Assembling should be performed before publishing package
76-
tasks.named("publish") {
77-
dependsOn("assemble")
118+
signing {
119+
sign(publishing.publications["release"])
78120
}

build.gradle.kts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,16 @@ plugins {
33
id("com.android.library").version("7.4.2").apply(false)
44
id("org.jetbrains.kotlin.android").version("1.9.10").apply(false)
55
id("org.jlleitschuh.gradle.ktlint").version("11.6.1").apply(true)
6+
id("io.github.gradle-nexus.publish-plugin").version("1.3.0").apply(true)
7+
}
8+
9+
nexusPublishing {
10+
this.repositories {
11+
sonatype {
12+
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
13+
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
14+
username = System.getenv("OSSRH_USERNAME")
15+
password = System.getenv("OSSRH_PASSWORD")
16+
}
17+
}
618
}

0 commit comments

Comments
 (0)