Skip to content

Commit

Permalink
Update maven publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
rthic23 committed Jun 3, 2024
1 parent d724007 commit 4ba73ac
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 25 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/release-aar.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Release React Native AAR
# This workflow is manually triggered to release a new React Native AAR version
on:
workflow_dispatch:

jobs:
release-aar:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Publish Maven Artifact
run: |
cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import
gpg --list-secret-keys --keyid-format LONG
yarn install
echo "signing.gnupg.keyName=${OSSRH_GPG_SECRET_KEY_ID}" >> gradle.properties
echo "signing.gnupg.passphrase=${OSSRH_GPG_SECRET_KEY_PASSWORD}" >> gradle.properties
echo "repositoryUsername=${OSSRH_SONATYPE_USERNAME}" >> gradle.properties
echo "repositoryPassword=${OSSRH_SONATYPE_PASSWORD}" >> gradle.properties
echo "signingKey=${OSSRH_GPG_SECRET_KEY}" >> gradle.properties
echo "signingPassword=${OSSRH_GPG_SECRET_KEY_PASSWORD}" >> gradle.properties
sed -i.bu 's/com.facebook.react/com.walmartlabs.ern/g' packages/react-native/ReactAndroid/gradle.properties
sed -i.bu 's/com.facebook.react/com.walmartlabs.ern/g' packages/react-native/ReactAndroid/hermes-engine/gradle.properties
./gradlew assembleRelease
./gradlew publishAllPublicationsToErnRepository --stacktrace
env:
OSSRH_GPG_SECRET_KEY_ID: ${{ secrets.OSSRH_GPG_SECRET_KEY_ID }}
OSSRH_GPG_SECRET_KEY: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
OSSRH_GPG_SECRET_KEY_PASSWORD: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
OSSRH_SONATYPE_USERNAME: ${{ secrets.OSSRH_SONATYPE_USERNAME }}
OSSRH_SONATYPE_PASSWORD: ${{ secrets.OSSRH_SONATYPE_PASSWORD }}
13 changes: 9 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ group = "com.facebook.react"

val ndkPath by extra(System.getenv("ANDROID_NDK"))
val ndkVersion by extra(System.getenv("ANDROID_NDK_VERSION"))
val sonatypeUsername = findProperty("SONATYPE_USERNAME")?.toString()
val sonatypePassword = findProperty("SONATYPE_PASSWORD")?.toString()
val sonatypeUsername = findProperty("repositoryUsername")?.toString()
val sonatypePassword = findProperty("repositoryPassword")?.toString()

nexusPublishing {
repositories {
Expand Down Expand Up @@ -99,9 +99,14 @@ tasks.register("publishAllToMavenTempLocal") {
":packages:react-native:ReactAndroid:hermes-engine:publishAllPublicationsToMavenTempLocalRepository")
}

tasks.register("publishAllPublicationsToErnRepository") {
description = "Publish all the artifacts to be available inside a Maven Local repository on /tmp."
dependsOn(":packages:react-native:ReactAndroid:publishAllPublicationsToErnRepository")
dependsOn(
":packages:react-native:ReactAndroid:hermes-engine:publishAllPublicationsToErnRepository")
}

tasks.register("publishAllToSonatype") {
description = "Publish all the artifacts to Sonatype (Maven Central or Snapshot repository)"
dependsOn(":packages:react-native:ReactAndroid:publishToSonatype")
dependsOn(":packages:react-native:ReactAndroid:external-artifacts:publishToSonatype")
dependsOn(":packages:react-native:ReactAndroid:hermes-engine:publishToSonatype")
}
2 changes: 1 addition & 1 deletion packages/react-native/ReactAndroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import kotlin.Pair
import de.undercouch.gradle.tasks.download.Download

version = VERSION_NAME
group = "com.facebook.react"
group = GROUP

// We download various C++ open-source dependencies into downloads.
// We then copy both the downloaded code and our custom makefiles and headers into third-party-ndk.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ def hermesiOSReleaseArtifact = artifacts.add('default', hermesiOSReleaseArtifact

apply from: "../publish.gradle"

publishing {
publications {
getByName("release") {
artifactId 'react-native-artifacts'
artifact hermesiOSDebugArtifact
artifact hermesiOSReleaseArtifact
}
}
}
// publishing {
// publications {
// getByName("release") {
// artifactId 'react-native-artifacts'
// artifact hermesiOSDebugArtifact
// artifact hermesiOSReleaseArtifact
// }
// }
// }
21 changes: 21 additions & 0 deletions packages/react-native/ReactAndroid/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,26 @@ FOLLY_VERSION=2021.07.22.00
GLOG_VERSION=0.3.5
LIBEVENT_VERSION=2.1.12

# Electrode Native Sonatype Publish
POM_URL=https://github.com/facebook/react-native
POM_SCM_URL=https://github.com/facebook/react-native.git
POM_SCM_CONNECTION=scm:git:https://github.com/facebook/react-native.git
POM_SCM_DEV_CONNECTION=scm:git:[email protected]:facebook/react-native.git
POM_DESCRIPTION=A framework for building native apps with React

POM_LICENCE_NAME=MIT License
POM_LICENCE_URL=https://github.com/facebook/react-native/blob/master/LICENSE
POM_LICENCE_DIST=repo

POM_DEVELOPER_ID=facebook
POM_DEVELOPER_NAME=Facebook
POM_DEVELOPER_EMAIL=[email protected]

SONATYPE_HOST=DEFAULT
RELEASE_SIGNING_ENABLED=true

REPOSITORY_URL_MAVEN_STAGING_DEFAULT=https://oss.sonatype.org/service/local/staging/deploy/maven2/
REPOSITORY_URL_MAVEN_SNAPSHOT_DEFAULT=https://oss.sonatype.org/content/repositories/snapshots/

android.useAndroidX=true
android.enableJetifier=true
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ plugins {
id("signing")
}

group = "com.facebook.react"
group = GROUP
version = parent.publishing_version
def cmakeVersion = parent.cmake_version

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
GROUP=com.facebook.react
android.disableAutomaticComponentCreation=true
33 changes: 23 additions & 10 deletions packages/react-native/ReactAndroid/publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,22 @@ apply plugin: 'maven-publish'
apply plugin: 'signing'

def isNightly = findProperty("isNightly")?.toBoolean()
def signingKey = findProperty("SIGNING_KEY")
def signingPwd = findProperty("SIGNING_PWD")
def signingKey = findProperty("signingKey")
def signingPwd = findProperty("signingPassword")

def reactAndroidProjectDir = project(':packages:react-native:ReactAndroid').projectDir
def androidOutputUrl = "file://${reactAndroidProjectDir}/../android"
def mavenTempLocalUrl = "file:///tmp/maven-local"

// ERN Publish to Maven Creds
def sonatypeUsername = findProperty("repositoryUsername")
def sonatypePassword = findProperty("repositoryPassword")
def ernMavenCentral = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"

def isReleaseBuild() {
return VERSION_NAME.contains("SNAPSHOT") == false
}

publishing {
publications {
release(MavenPublication) {
Expand Down Expand Up @@ -73,15 +82,19 @@ publishing {
name = "mavenTempLocal"
url = mavenTempLocalUrl
}
maven {
name = "ern"
url = ernMavenCentral
credentials {
username = sonatypeUsername
password = sonatypePassword
}
}
}

if (signingKey && signingPwd) {
logger.info("PGP Key found - Signing enabled")
signing {
useInMemoryPgpKeys(signingKey, signingPwd)
sign(publishing.publications.release)
}
} else {
logger.info("Signing disabled as the PGP key was not found")
signing {
required { isReleaseBuild() }
useGpgCmd()
sign(publishing.publications.release)
}
}

0 comments on commit 4ba73ac

Please sign in to comment.