Skip to content

Commit dd7f765

Browse files
authored
ci: adds release please support for launchdarkly-observability-android package (#145)
This PR adds release please and manual publish actions for the android observability package. Historically this doesn't work the first time, but have done as much local testing as I can due to tokens/permission required for full execution.
1 parent 76fd41e commit dd7f765

File tree

12 files changed

+223
-3
lines changed

12 files changed

+223
-3
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: 'Publish Android SDK'
2+
description: 'Build and publish Android SDK packages to Maven Central'
3+
4+
inputs:
5+
workspace-path:
6+
description: 'Path to the Android SDK workspace'
7+
required: true
8+
default: 'sdk/@launchdarkly/observability-android'
9+
java_version:
10+
description: 'The Java version to use.'
11+
required: false
12+
default: '17'
13+
java_distribution:
14+
description: 'The Java distribution to use.'
15+
required: false
16+
default: 'temurin'
17+
aws-role-arn:
18+
description: 'AWS role ARN for accessing secrets'
19+
required: true
20+
dry-run:
21+
description: 'Whether to run the publish in dry-run mode'
22+
required: false
23+
default: 'false'
24+
prerelease:
25+
description: 'Whether to publish a prerelease version'
26+
required: false
27+
default: 'false'
28+
29+
runs:
30+
using: 'composite'
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
35+
- name: Setup Java
36+
uses: actions/setup-java@v4
37+
with:
38+
distribution: ${{ inputs.java_distribution }}
39+
java-version: ${{ inputs.java_version }}
40+
41+
- name: Setup Android SDK
42+
uses: android-actions/setup-android@v3
43+
44+
- uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.2.0
45+
name: Get secrets
46+
with:
47+
aws_assume_role: ${{ inputs.aws-role-arn }}
48+
ssm_parameter_pairs: |
49+
/production/common/releasing/sonatype/central/username = SONATYPE_USER_NAME,
50+
/production/common/releasing/sonatype/central/password = SONATYPE_PASSWORD,
51+
/production/common/releasing/android_code_signing/private_key_id = SIGNING_KEY_ID,
52+
/production/common/releasing/android_code_signing/private_key_passphrase = SIGNING_KEY_PASSPHRASE
53+
s3_path_pairs: 'launchdarkly-releaser/android/code-signing-keyring.gpg = code-signing-keyring.gpg'
54+
55+
- name: Publish Library
56+
shell: bash
57+
if: ${{ inputs.dry-run != 'true' }}
58+
working-directory: ${{ inputs.workspace-path }}
59+
env:
60+
LD_RELEASE_IS_PRERELEASE: ${{ inputs.prerelease }}
61+
SIGNING_KEY_ID: ${{ env.SIGNING_KEY_ID }}
62+
SIGNING_KEY_PASSPHRASE: ${{ env.SIGNING_KEY_PASSPHRASE }}
63+
SIGNING_SECRET_KEY_RING_FILE: ${{ github.workspace }}/code-signing-keyring.gpg
64+
SONATYPE_USER_NAME: ${{ env.SONATYPE_USER_NAME }}
65+
SONATYPE_PASSWORD: ${{ env.SONATYPE_PASSWORD }}
66+
run: source $GITHUB_ACTION_PATH/publish.sh
67+
68+
- name: Dry Run Publish Library
69+
shell: bash
70+
if: ${{ inputs.dry-run == 'true' }}
71+
run: echo "Dry run. Not publishing."
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
set -ue
4+
5+
echo "Publishing to Sonatype"
6+
if [ "${LD_RELEASE_IS_PRERELEASE}" == "true" ]; then
7+
echo "PRERELEASE"
8+
./gradlew publishToSonatype -Psigning.keyId="${SIGNING_KEY_ID}" -Psigning.password="${SIGNING_KEY_PASSPHRASE}" -Psigning.secretKeyRingFile="${SIGNING_SECRET_KEY_RING_FILE}" -PsonatypeUsername="${SONATYPE_USER_NAME}" -PsonatypePassword="${SONATYPE_PASSWORD}" || {
9+
echo "Gradle publish/release failed" >&2
10+
exit 1
11+
}
12+
else
13+
echo "RELEASE"
14+
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -Psigning.keyId="${SIGNING_KEY_ID}" -Psigning.password="${SIGNING_KEY_PASSPHRASE}" -Psigning.secretKeyRingFile="${SIGNING_SECRET_KEY_RING_FILE}" -PsonatypeUsername="${SONATYPE_USER_NAME}" -PsonatypePassword="${SONATYPE_PASSWORD}" || {
15+
echo "Gradle publish/release failed" >&2
16+
exit 1
17+
}
18+
fi

.github/workflows/manual-publish.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ on:
2222
description: 'Should release @launchdarkly/observability-python package.'
2323
type: boolean
2424
required: true
25+
release_launchdarkly_android:
26+
description: 'Should release @launchdarkly/observability-android package.'
27+
type: boolean
28+
required: true
2529
python_tag_name:
2630
description: 'The tag name for the python package. Should be set when publishing a python package.'
2731
type: string
@@ -124,3 +128,18 @@ jobs:
124128
base64-subjects: '${{ needs.publish-python-sdk.outputs.package-hashes }}'
125129
upload-assets: true
126130
upload-tag-name: ${{ inputs.python_tag_name }}
131+
132+
publish-android-sdk:
133+
runs-on: ubuntu-latest
134+
if: ${{ inputs.release_launchdarkly_android == true }}
135+
permissions:
136+
id-token: write
137+
steps:
138+
- name: Publish Android SDK
139+
id: publish
140+
uses: ./.github/actions/publish-android-sdk
141+
with:
142+
workspace-path: sdk/@launchdarkly/observability-android
143+
aws-role-arn: ${{ vars.AWS_ROLE_ARN }}
144+
dry-run: ${{ inputs.dry-run }}
145+
prerelease: ${{ inputs.prerelease }}

.github/workflows/release-please.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ jobs:
1414
outputs:
1515
python-plugin-released: ${{ steps.release.outputs['sdk/@launchdarkly/observability-python--release_created'] }}
1616
python-plugin-tag-name: ${{ steps.release.outputs['sdk/@launchdarkly/observability-python--tag_name'] }}
17+
android-plugin-released: ${{ steps.release.outputs['sdk/@launchdarkly/observability-android--release_created'] }}
18+
android-plugin-tag-name: ${{ steps.release.outputs['sdk/@launchdarkly/observability-android--tag_name'] }}
1719
steps:
1820
- uses: googleapis/release-please-action@a02a34c4d625f9be7cb89156071d8567266a2445
1921
id: release
@@ -65,3 +67,21 @@ jobs:
6567
base64-subjects: '${{ needs.release-python-plugin.outputs.package-hashes }}'
6668
upload-assets: true
6769
upload-tag-name: ${{ needs.release-package.outputs.python-plugin-tag-name }}
70+
71+
release-android-plugin:
72+
runs-on: ubuntu-latest
73+
permissions:
74+
id-token: write # Used for publishing secrets and documentation.
75+
contents: write
76+
needs: ['release-package']
77+
if: ${{ needs.release-package.outputs.android-plugin-released == 'true' }}
78+
steps:
79+
- name: Checkout
80+
uses: actions/checkout@v4
81+
82+
- name: Publish Android SDK
83+
id: publish
84+
uses: ./.github/actions/publish-android-sdk
85+
with:
86+
workspace-path: sdk/@launchdarkly/observability-android
87+
aws-role-arn: ${{ vars.AWS_ROLE_ARN }}

e2e/android/app/src/main/java/com/example/androidobservability/ViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.example.androidobservability
22

3-
import LDObserve
43
import androidx.lifecycle.ViewModel
54
import com.launchdarkly.observability.interfaces.Metric
5+
import com.launchdarkly.observability.sdk.LDObserve
66
import com.launchdarkly.sdk.android.LDClient
77
import io.opentelemetry.api.common.AttributeKey
88
import io.opentelemetry.api.common.Attributes

release-please-config.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
"include-v-in-tag": false,
88
"extra-files": ["PROVENANCE.md"],
99
"include-component-in-tag": true
10+
},
11+
"sdk/@launchdarkly/observability-android": {
12+
"package-name": "launchdarkly-observability-android",
13+
"release-type": "simple",
14+
"versioning": "default",
15+
"include-v-in-tag": false,
16+
"include-component-in-tag": true,
17+
"extra-files": ["gradle.properties"]
1018
}
1119
}
1220
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
plugins {
2+
id("io.github.gradle-nexus.publish-plugin").version("2.0.0").apply(true)
3+
}
4+
5+
nexusPublishing {
6+
this.repositories {
7+
sonatype {
8+
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
9+
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
10+
}
11+
}
12+
}

sdk/@launchdarkly/observability-android/gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ org.gradle.configuration-cache=true
55

66
android.useAndroidX=true
77

8+
#x-release-please-start-version
9+
version=0.1.0
10+
#x-release-please-end

sdk/@launchdarkly/observability-android/lib/build.gradle.kts

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
plugins {
22
// Apply the Android library plugin
33
id("com.android.library")
4+
id("maven-publish")
5+
id("signing")
46

57
// Apply the Kotlin Android plugin for Android-compatible Kotlin support.
68
alias(libs.plugins.kotlin.android)
@@ -34,13 +36,15 @@ dependencies {
3436
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
3537
}
3638

39+
val releaseVersion = version.toString()
40+
3741
android {
3842
namespace = "com.launchdarkly.observability"
3943
compileSdk = 30
4044

4145
defaultConfig {
4246
minSdk = 24
43-
47+
version = releaseVersion
4448
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
4549
}
4650

@@ -56,4 +60,63 @@ android {
5660
kotlinOptions {
5761
jvmTarget = "1.8"
5862
}
63+
64+
publishing {
65+
singleVariant("release") {
66+
withJavadocJar()
67+
withSourcesJar()
68+
}
69+
}
70+
}
71+
72+
publishing {
73+
publications {
74+
create<MavenPublication>("release") {
75+
groupId = "com.launchdarkly"
76+
artifactId = "launchdarkly-observability-android"
77+
version = releaseVersion
78+
79+
pom {
80+
name.set("LaunchDarkly Observability Android SDK")
81+
description.set(
82+
"Official LaunchDarkly Observability Android SDK for use with the LaunchDarkly Android SDK."
83+
)
84+
url.set("https://github.com/launchdarkly/observability-sdk/")
85+
organization {
86+
name.set("LaunchDarkly")
87+
url.set("https://launchdarkly.com/")
88+
}
89+
developers {
90+
developer {
91+
id.set("sdks")
92+
name.set("LaunchDarkly SDK Team")
93+
email.set("sdks@launchdarkly.com")
94+
}
95+
}
96+
licenses {
97+
license {
98+
name.set("The Apache License, Version 2.0")
99+
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
100+
}
101+
}
102+
scm {
103+
connection.set(
104+
"scm:git:https://github.com/launchdarkly/observability-sdk.git"
105+
)
106+
developerConnection.set(
107+
"scm:git:ssh:github.com/launchdarkly/observability-sdk.git"
108+
)
109+
url.set("https://github.com/launchdarkly/observability-sdk/")
110+
}
111+
}
112+
113+
afterEvaluate {
114+
from(components["release"])
115+
}
116+
}
117+
}
118+
}
119+
120+
signing {
121+
sign(publishing.publications["release"])
59122
}

sdk/@launchdarkly/observability-android/lib/src/main/kotlin/com/launchdarkly/observability/client/ObservabilityClient.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package com.launchdarkly.observability.client
2+
13
import android.app.Application
24
import com.launchdarkly.observability.client.InstrumentationManager
35
import com.launchdarkly.observability.interfaces.Metric

0 commit comments

Comments
 (0)