Skip to content

Commit f7c33f0

Browse files
committed
Update maven publishing
1 parent e30475d commit f7c33f0

File tree

6 files changed

+116
-25
lines changed

6 files changed

+116
-25
lines changed

.github/workflows/release-aar.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Release React Native AAR
2+
# This workflow is manually triggered to release a new React Native AAR version
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
release-aar:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
12+
- name: Install Specific NDK Version
13+
run: |
14+
# Extract the NDK version from libs.versions.toml
15+
NDK_VERSION=$(grep 'ndkVersion =' packages/react-native/gradle/libs.versions.toml | sed -E 's/.*"([0-9.]+)".*/\1/')
16+
echo "Installing NDK version: $NDK_VERSION"
17+
18+
# Install the specific NDK version
19+
echo "y" | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install "ndk;$NDK_VERSION"
20+
21+
# Ensure it's the one that will be used
22+
echo "ndk.dir=$ANDROID_HOME/ndk/$NDK_VERSION" >> local.properties
23+
echo "ORG_GRADLE_PROJECT_ndkPath=$ANDROID_HOME/ndk/$NDK_VERSION" >> $GITHUB_ENV
24+
25+
- name: Publish Maven Artifact
26+
run: |
27+
cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import
28+
gpg --list-secret-keys --keyid-format LONG
29+
yarn install
30+
echo "signing.gnupg.keyName=${OSSRH_GPG_SECRET_KEY_ID}" >> gradle.properties
31+
echo "signing.gnupg.passphrase=${OSSRH_GPG_SECRET_KEY_PASSWORD}" >> gradle.properties
32+
echo "repositoryUsername=${OSSRH_SONATYPE_USERNAME}" >> gradle.properties
33+
echo "repositoryPassword=${OSSRH_SONATYPE_PASSWORD}" >> gradle.properties
34+
echo "signingKey=${OSSRH_GPG_SECRET_KEY}" >> gradle.properties
35+
echo "signingPassword=${OSSRH_GPG_SECRET_KEY_PASSWORD}" >> gradle.properties
36+
sed -i.bu 's/com.facebook.react/com.walmartlabs.ern/g' packages/react-native/ReactAndroid/gradle.properties
37+
sed -i.bu 's/com.facebook.react/com.walmartlabs.ern/g' packages/react-native/ReactAndroid/hermes-engine/gradle.properties
38+
39+
# Use explicit flags to ensure NDK path is correctly set
40+
./gradlew assembleRelease -PndkPath=$ANDROID_HOME/ndk/$NDK_VERSION
41+
./gradlew publishAllPublicationsToErnRepository --stacktrace -PndkPath=$ANDROID_HOME/ndk/$NDK_VERSION
42+
env:
43+
OSSRH_GPG_SECRET_KEY_ID: ${{ secrets.OSSRH_GPG_SECRET_KEY_ID }}
44+
OSSRH_GPG_SECRET_KEY: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
45+
OSSRH_GPG_SECRET_KEY_PASSWORD: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
46+
OSSRH_SONATYPE_USERNAME: ${{ secrets.OSSRH_SONATYPE_USERNAME }}
47+
OSSRH_SONATYPE_PASSWORD: ${{ secrets.OSSRH_SONATYPE_PASSWORD }}

build.gradle.kts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ group = "com.facebook.react"
4646

4747
val ndkPath by extra(System.getenv("ANDROID_NDK"))
4848
val ndkVersion by extra(System.getenv("ANDROID_NDK_VERSION") ?: libs.versions.ndkVersion.get())
49-
val sonatypeUsername = findProperty("SONATYPE_USERNAME")?.toString()
50-
val sonatypePassword = findProperty("SONATYPE_PASSWORD")?.toString()
49+
val sonatypeUsername = findProperty("repositoryUsername")?.toString()
50+
val sonatypePassword = findProperty("repositoryPassword")?.toString()
5151

5252
nexusPublishing {
5353
repositories {
@@ -99,10 +99,16 @@ tasks.register("publishAllToMavenTempLocal") {
9999
":packages:react-native:ReactAndroid:hermes-engine:publishAllPublicationsToMavenTempLocalRepository")
100100
}
101101

102+
tasks.register("publishAllPublicationsToErnRepository") {
103+
description = "Publish all the artifacts to be available inside a Maven Local repository on /tmp."
104+
dependsOn(":packages:react-native:ReactAndroid:publishAllPublicationsToErnRepository")
105+
dependsOn(
106+
":packages:react-native:ReactAndroid:hermes-engine:publishAllPublicationsToErnRepository")
107+
}
108+
102109
tasks.register("publishAndroidToSonatype") {
103110
description = "Publish the Android artifacts to Sonatype (Maven Central or Snapshot repository)"
104111
dependsOn(":packages:react-native:ReactAndroid:publishToSonatype")
105-
dependsOn(":packages:react-native:ReactAndroid:hermes-engine:publishToSonatype")
106112
}
107113

108114
if (project.findProperty("react.internal.useHermesNightly")?.toString()?.toBoolean() == true) {

packages/react-native/ReactAndroid/external-artifacts/build.gradle.kts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,16 @@ val hermesDSYMReleaseArtifact: PublishArtifact =
5353
classifier = "hermes-framework-dSYM-release"
5454
}
5555

56-
apply(from = "../publish.gradle")
56+
// apply(from = "../publish.gradle")
5757

58-
publishing {
59-
publications {
60-
getByName("release", MavenPublication::class) {
61-
artifactId = "react-native-artifacts"
62-
artifact(hermesiOSDebugArtifact)
63-
artifact(hermesiOSReleaseArtifact)
64-
artifact(hermesDSYMDebugArtifact)
65-
artifact(hermesDSYMReleaseArtifact)
66-
}
67-
}
68-
}
58+
// publishing {
59+
// publications {
60+
// getByName("release", MavenPublication::class) {
61+
// artifactId = "react-native-artifacts"
62+
// artifact(hermesiOSDebugArtifact)
63+
// artifact(hermesiOSReleaseArtifact)
64+
// artifact(hermesDSYMDebugArtifact)
65+
// artifact(hermesDSYMReleaseArtifact)
66+
// }
67+
// }
68+
// }

packages/react-native/ReactAndroid/gradle.properties

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
11
VERSION_NAME=0.77.2
22
react.internal.publishingGroup=com.facebook.react
33

4+
# Electrode Native Sonatype Publish
5+
POM_URL=https://github.com/facebook/react-native
6+
POM_SCM_URL=https://github.com/facebook/react-native.git
7+
POM_SCM_CONNECTION=scm:git:https://github.com/facebook/react-native.git
8+
POM_SCM_DEV_CONNECTION=scm:git:[email protected]:facebook/react-native.git
9+
POM_DESCRIPTION=A framework for building native apps with React
10+
11+
POM_LICENCE_NAME=MIT License
12+
POM_LICENCE_URL=https://github.com/facebook/react-native/blob/master/LICENSE
13+
POM_LICENCE_DIST=repo
14+
15+
POM_DEVELOPER_ID=facebook
16+
POM_DEVELOPER_NAME=Facebook
17+
POM_DEVELOPER_EMAIL=[email protected]
18+
19+
SONATYPE_HOST=DEFAULT
20+
RELEASE_SIGNING_ENABLED=true
21+
22+
REPOSITORY_URL_MAVEN_STAGING_DEFAULT=https://oss.sonatype.org/service/local/staging/deploy/maven2/
23+
REPOSITORY_URL_MAVEN_SNAPSHOT_DEFAULT=https://oss.sonatype.org/content/repositories/snapshots/
24+
25+
426
android.useAndroidX=true
527

628
# We want to have more fine grained control on the Java version for
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
GROUP=com.facebook.react
12
android.disableAutomaticComponentCreation=true

packages/react-native/ReactAndroid/publish.gradle

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,23 @@ apply plugin: 'maven-publish'
99
apply plugin: 'signing'
1010

1111
def isSnapshot = findProperty("isSnapshot")?.toBoolean()
12-
def signingKey = findProperty("SIGNING_KEY")
13-
def signingPwd = findProperty("SIGNING_PWD")
12+
def signingKey = findProperty("signingKey")
13+
def signingPwd = findProperty("signingPassword")
1414

1515
def reactAndroidProjectDir = project(':packages:react-native:ReactAndroid').projectDir
1616
def mavenTempLocalUrl = "file:///tmp/maven-local"
1717

18+
19+
// ERN Publish to Maven Creds
20+
def sonatypeUsername = findProperty("repositoryUsername")
21+
def sonatypePassword = findProperty("repositoryPassword")
22+
def ernMavenCentral = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
23+
24+
def isReleaseBuild() {
25+
return VERSION_NAME.contains("SNAPSHOT") == false
26+
}
27+
28+
1829
publishing {
1930
publications {
2031
release(MavenPublication) {
@@ -68,15 +79,19 @@ publishing {
6879
name = "mavenTempLocal"
6980
url = mavenTempLocalUrl
7081
}
82+
maven {
83+
name = "ern"
84+
url = ernMavenCentral
85+
credentials {
86+
username = sonatypeUsername
87+
password = sonatypePassword
88+
}
89+
}
7190
}
7291

73-
if (signingKey && signingPwd) {
74-
logger.info("PGP Key found - Signing enabled")
75-
signing {
76-
useInMemoryPgpKeys(signingKey, signingPwd)
77-
sign(publishing.publications.release)
78-
}
79-
} else {
80-
logger.info("Signing disabled as the PGP key was not found")
92+
signing {
93+
required { isReleaseBuild() }
94+
useGpgCmd()
95+
sign(publishing.publications.release)
8196
}
8297
}

0 commit comments

Comments
 (0)