Skip to content

Commit 9cee3e0

Browse files
committed
Update maven publishing
1 parent e30475d commit 9cee3e0

File tree

6 files changed

+131
-25
lines changed

6 files changed

+131
-25
lines changed

.github/workflows/release-aar.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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: Debug NDK Configuration
13+
run: |
14+
echo "ANDROID_HOME: $ANDROID_HOME"
15+
ls -la $ANDROID_HOME/ndk/
16+
echo "Current NDK_HOME: $ANDROID_NDK_HOME"
17+
18+
- name: Clear any pre-existing local.properties
19+
run: |
20+
rm -f local.properties
21+
rm -f packages/react-native/ReactAndroid/local.properties
22+
rm -f android/local.properties
23+
24+
- name: Configure environment for correct NDK
25+
run: |
26+
# Extract NDK version
27+
NDK_VERSION=$(grep 'ndkVersion =' packages/react-native/gradle/libs.versions.toml | sed -E 's/.*"([0-9.]+)".*/\1/')
28+
echo "Using NDK version from libs.versions.toml: $NDK_VERSION"
29+
30+
# Install the correct NDK version
31+
echo "y" | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install "ndk;$NDK_VERSION"
32+
33+
# Create symlink to make the installed NDK the default
34+
sudo rm -rf $ANDROID_HOME/ndk/27.2.12479018
35+
sudo ln -sf $ANDROID_HOME/ndk/$NDK_VERSION $ANDROID_HOME/ndk/27.2.12479018
36+
37+
# Verify symlink
38+
ls -la $ANDROID_HOME/ndk/
39+
readlink -f $ANDROID_HOME/ndk/27.2.12479018
40+
41+
- name: Publish Maven Artifact
42+
run: |
43+
cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import
44+
gpg --list-secret-keys --keyid-format LONG
45+
yarn install
46+
echo "signing.gnupg.keyName=${OSSRH_GPG_SECRET_KEY_ID}" >> gradle.properties
47+
echo "signing.gnupg.passphrase=${OSSRH_GPG_SECRET_KEY_PASSWORD}" >> gradle.properties
48+
echo "repositoryUsername=${OSSRH_SONATYPE_USERNAME}" >> gradle.properties
49+
echo "repositoryPassword=${OSSRH_SONATYPE_PASSWORD}" >> gradle.properties
50+
echo "signingKey=${OSSRH_GPG_SECRET_KEY}" >> gradle.properties
51+
echo "signingPassword=${OSSRH_GPG_SECRET_KEY_PASSWORD}" >> gradle.properties
52+
sed -i.bu 's/com.facebook.react/com.walmartlabs.ern/g' packages/react-native/ReactAndroid/gradle.properties
53+
sed -i.bu 's/com.facebook.react/com.walmartlabs.ern/g' packages/react-native/ReactAndroid/hermes-engine/gradle.properties
54+
# Use the ndkVersion property explicitly
55+
./gradlew assembleRelease -PndkVersion=27.1.12297006
56+
./gradlew publishAllPublicationsToErnRepository --stacktrace -PndkVersion=27.1.12297006
57+
env:
58+
OSSRH_GPG_SECRET_KEY_ID: ${{ secrets.OSSRH_GPG_SECRET_KEY_ID }}
59+
OSSRH_GPG_SECRET_KEY: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
60+
OSSRH_GPG_SECRET_KEY_PASSWORD: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
61+
OSSRH_SONATYPE_USERNAME: ${{ secrets.OSSRH_SONATYPE_USERNAME }}
62+
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)