From 3ce06cc96969bcf089c3ad8af722f97b64b0d655 Mon Sep 17 00:00:00 2001 From: Jay Koutavas Date: Tue, 20 May 2025 21:45:33 -0400 Subject: [PATCH 1/7] Checkpoint --- .github/workflows/publish-isubscribed.yml | 78 ++++++ .github/workflows/publish-release.yml | 231 ------------------ .../ReactAndroid/build.gradle.kts | 84 +++++-- 3 files changed, 145 insertions(+), 248 deletions(-) create mode 100644 .github/workflows/publish-isubscribed.yml delete mode 100644 .github/workflows/publish-release.yml diff --git a/.github/workflows/publish-isubscribed.yml b/.github/workflows/publish-isubscribed.yml new file mode 100644 index 00000000000000..1843d8a7a690ba --- /dev/null +++ b/.github/workflows/publish-isubscribed.yml @@ -0,0 +1,78 @@ +name: Publish ReactAndroid AAR to GitHub Packages + +on: + push: + tags: + - 'v*' # Trigger publishing when a tag like v1.0.0, v0.2.1 is pushed + +jobs: + publish-aar: + name: Publish ReactAndroid AAR + runs-on: ubuntu-latest + permissions: + contents: read # To checkout the repository + packages: write # To publish packages to GitHub Packages + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetches all history, useful for versioning or changelogs + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + - name: Set up NDK + uses: nttld/setup-ndk@v1 + id: setup-ndk + with: + # Specify the NDK version your ReactAndroid build requires. + # This should match the version that was causing CXX1100 errors if not aligned. + ndk-version: r27 # Example for NDK 27. Adjust if 27.0.12077973 is r27 or a specific r2X version. Check nttld/setup-ndk docs for exact version string. + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18.x' # Use a Node.js LTS version compatible with your RN version + + - name: Install Yarn + run: npm install -g yarn + + - name: Install JavaScript dependencies + # This step is crucial if your ReactAndroid build relies on codegen or other JS tooling. + # Adjust working-directory if your main package.json/yarn.lock is not in './packages/react-native'. + # If your JS project root is the repository root, you can remove `working-directory`. + run: yarn install --frozen-lockfile + working-directory: ./packages/react-native + + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v2 + + - name: Setup Gradle + # This action also handles caching Gradle dependencies for faster builds. + uses: gradle/actions/setup-gradle@v3 + + - name: Get version from tag + id: get_version + # Extracts the version number from the tag (e.g., v1.2.3 -> 1.2.3) + # If your tags don't have a 'v' prefix, use: echo "VERSION=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT + run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT + + - name: Publish ReactAndroid AAR to GitHub Packages + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_ACTOR: ${{ github.actor }} + # This property name 'libraryVersion' should match what you use in your + # ReactAndroid/build.gradle.kts (e.g., project.property("libraryVersion") or rootProject.extra["libraryVersion"]) + ORG_GRADLE_PROJECT_libraryVersion: ${{ steps.get_version.outputs.VERSION }} + # Pass the NDK path to Gradle. Your build.gradle.kts should be configured to use this. + ANDROID_NDK_LATEST_PATH: ${{ steps.setup-ndk.outputs.ndk-path }} # nttld/setup-ndk provides this output + # Common Gradle options for CI + GRADLE_OPTS: "-Dorg.gradle.daemon=false" + run: ./gradlew \ + :packages:react-native:ReactAndroid:publishDebugPublicationToGitHubPackagesRepository \ + :packages:react-native:ReactAndroid:publishReleasePublicationToGitHubPackagesRepository \ + --info --stacktrace \ No newline at end of file diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml deleted file mode 100644 index e3b151e875f26a..00000000000000 --- a/.github/workflows/publish-release.yml +++ /dev/null @@ -1,231 +0,0 @@ -name: Publish Release -on: - push: - tags: - - "v0.*.*" # This should match v0.X.Y - - "v0.*.*-rc.*" # This should match v0.X.Y-RC.0 -jobs: - set_release_type: - runs-on: ubuntu-latest - if: github.repository == 'facebook/react-native' - outputs: - RELEASE_TYPE: ${{ steps.set_release_type.outputs.RELEASE_TYPE }} - env: - EVENT_NAME: ${{ github.event_name }} - REF: ${{ github.ref }} - steps: - - id: set_release_type - run: | - echo "Setting release type to release" - echo "RELEASE_TYPE=release" >> $GITHUB_OUTPUT - - prepare_hermes_workspace: - runs-on: ubuntu-latest - env: - HERMES_WS_DIR: /tmp/hermes - HERMES_VERSION_FILE: packages/react-native/sdks/.hermesversion - outputs: - react-native-version: ${{ steps.prepare-hermes-workspace.outputs.react-native-version }} - hermes-version: ${{ steps.prepare-hermes-workspace.outputs.hermes-version }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Prepare Hermes Workspace - id: prepare-hermes-workspace - uses: ./.github/actions/prepare-hermes-workspace - with: - hermes-ws-dir: ${{ env.HERMES_WS_DIR }} - hermes-version-file: ${{ env.HERMES_VERSION_FILE }} - - build_hermesc_apple: - runs-on: macos-13 - needs: prepare_hermes_workspace - env: - HERMES_WS_DIR: /tmp/hermes - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build HermesC Apple - uses: ./.github/actions/build-hermesc-apple - with: - hermes-version: ${{ needs.prepare_hermes_workspace.output.hermes-version }} - react-native-version: ${{ needs.prepare_hermes_workspace.output.react-native-version }} - build_apple_slices_hermes: - runs-on: macos-14 - needs: [build_hermesc_apple, prepare_hermes_workspace] - env: - HERMES_WS_DIR: /tmp/hermes - HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin - HERMES_OSXBIN_ARTIFACTS_DIR: /tmp/hermes/osx-bin - IOS_DEPLOYMENT_TARGET: "15.1" - XROS_DEPLOYMENT_TARGET: "1.0" - MAC_DEPLOYMENT_TARGET: "10.15" - strategy: - fail-fast: false - matrix: - flavor: [Debug, Release] - slice: [macosx, iphoneos, iphonesimulator, appletvos, appletvsimulator, catalyst, xros, xrsimulator] - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build Slice - uses: ./.github/actions/build-apple-slices-hermes - with: - flavor: ${{ matrix.flavor }} - slice: ${{ matrix.slice}} - hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }} - react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }} - - build_hermes_macos: - runs-on: macos-13 - needs: [build_apple_slices_hermes, prepare_hermes_workspace] - env: - HERMES_WS_DIR: /tmp/hermes - HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin - continue-on-error: true - strategy: - fail-fast: false - matrix: - flavor: [Debug, Release] - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build Hermes MacOS - uses: ./.github/actions/build-hermes-macos - with: - hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }} - react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }} - flavor: ${{ matrix.flavor }} - prebuild_apple_dependencies: - uses: ./.github/workflows/prebuild-ios.yml - - build_hermesc_linux: - runs-on: ubuntu-latest - needs: prepare_hermes_workspace - env: - HERMES_WS_DIR: /tmp/hermes - HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build HermesC Linux - uses: ./.github/actions/build-hermesc-linux - with: - hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }} - react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }} - - build_hermesc_windows: - runs-on: windows-2019 - needs: prepare_hermes_workspace - env: - HERMES_WS_DIR: 'D:\tmp\hermes' - HERMES_TARBALL_ARTIFACTS_DIR: 'D:\tmp\hermes\hermes-runtime-darwin' - HERMES_OSXBIN_ARTIFACTS_DIR: 'D:\tmp\hermes\osx-bin' - ICU_URL: "https://github.com/unicode-org/icu/releases/download/release-64-2/icu4c-64_2-Win64-MSVC2017.zip" - MSBUILD_DIR: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin' - CMAKE_DIR: 'C:\Program Files\CMake\bin' - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build HermesC Windows - uses: ./.github/actions/build-hermesc-windows - with: - hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }} - react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }} - - build_android: - runs-on: 8-core-ubuntu - needs: [set_release_type] - container: - image: reactnativecommunity/react-native-android:latest - env: - TERM: "dumb" - GRADLE_OPTS: "-Dorg.gradle.daemon=false" - ORG_GRADLE_PROJECT_SIGNING_PWD: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_PWD }} - ORG_GRADLE_PROJECT_SIGNING_KEY: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_KEY }} - ORG_GRADLE_PROJECT_SONATYPE_USERNAME: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_USERNAME }} - ORG_GRADLE_PROJECT_SONATYPE_PASSWORD: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_PASSWORD }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build Android - uses: ./.github/actions/build-android - with: - release-type: ${{ needs.set_release_type.outputs.RELEASE_TYPE }} - gradle-cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }} - - build_npm_package: - runs-on: 8-core-ubuntu - needs: - [ - set_release_type, - prepare_hermes_workspace, - build_hermes_macos, - build_hermesc_linux, - build_hermesc_windows, - build_android, - prebuild_apple_dependencies, - ] - container: - image: reactnativecommunity/react-native-android:latest - env: - TERM: "dumb" - GRADLE_OPTS: "-Dorg.gradle.daemon=false" - # By default we only build ARM64 to save time/resources. For release/nightlies, we override this value to build all archs. - ORG_GRADLE_PROJECT_reactNativeArchitectures: "arm64-v8a" - env: - HERMES_WS_DIR: /tmp/hermes - GHA_NPM_TOKEN: ${{ secrets.GHA_NPM_TOKEN }} - ORG_GRADLE_PROJECT_SIGNING_PWD: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_PWD }} - ORG_GRADLE_PROJECT_SIGNING_KEY: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_KEY }} - ORG_GRADLE_PROJECT_SONATYPE_USERNAME: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_USERNAME }} - ORG_GRADLE_PROJECT_SONATYPE_PASSWORD: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_PASSWORD }} - REACT_NATIVE_BOT_GITHUB_TOKEN: ${{ secrets.REACT_NATIVE_BOT_GITHUB_TOKEN }} - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - fetch-tags: true - - name: Build and Publish NPM Package - uses: ./.github/actions/build-npm-package - with: - hermes-ws-dir: ${{ env.HERMES_WS_DIR }} - release-type: ${{ needs.set_release_type.outputs.RELEASE_TYPE }} - gha-npm-token: ${{ env.GHA_NPM_TOKEN }} - gradle-cache-encryption-key: ${{ secrets.GRADLE_CACHE_ENCRYPTION_KEY }} - - name: Publish @react-native-community/template - id: publish-template-to-npm - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.REACT_NATIVE_BOT_GITHUB_TOKEN }} - script: | - const {publishTemplate} = require('./.github/workflow-scripts/publishTemplate.js') - const version = "${{ github.ref_name }}" - const isDryRun = false - await publishTemplate(github, version, isDryRun); - - name: Wait for template to be published - timeout-minutes: 3 - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.REACT_NATIVE_BOT_GITHUB_TOKEN }} - script: | - const {verifyPublishedTemplate, isLatest} = require('./.github/workflow-scripts/publishTemplate.js') - const version = "${{ github.ref_name }}" - await verifyPublishedTemplate(version, isLatest()); - - name: Update rn-diff-purge to generate upgrade-support diff - run: | - curl -X POST https://api.github.com/repos/react-native-community/rn-diff-purge/dispatches \ - -H "Accept: application/vnd.github.v3+json" \ - -H "Authorization: Bearer $REACT_NATIVE_BOT_GITHUB_TOKEN" \ - -d "{\"event_type\": \"publish\", \"client_payload\": { \"version\": \"${{ github.ref_name }}\" }}" - - name: Verify Release is on NPM - timeout-minutes: 3 - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.REACT_NATIVE_BOT_GITHUB_TOKEN }} - script: | - const {verifyReleaseOnNpm} = require('./.github/workflow-scripts/verifyReleaseOnNpm.js'); - const {isLatest} = require('./.github/workflow-scripts/publishTemplate.js'); - const version = "${{ github.ref_name }}"; - await verifyReleaseOnNpm(version, isLatest()); diff --git a/packages/react-native/ReactAndroid/build.gradle.kts b/packages/react-native/ReactAndroid/build.gradle.kts index 7658a23fce3b62..bd6ece72be72bc 100644 --- a/packages/react-native/ReactAndroid/build.gradle.kts +++ b/packages/react-native/ReactAndroid/build.gradle.kts @@ -21,9 +21,12 @@ plugins { alias(libs.plugins.kotlin.android) } -version = project.findProperty("VERSION_NAME")?.toString()!! +// Use 'libraryVersion' property for CI/command-line, fallback to VERSION_NAME, then SNAPSHOT +version = project.findProperty("libraryVersion")?.toString() + ?: project.findProperty("VERSION_NAME")?.toString() + ?: "0.0.0-SNAPSHOT" -group = "com.facebook.react" +group = "com.github.isubscribed" // Your GitHub Packages group ID // 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. @@ -40,7 +43,8 @@ val reactNativeRootDir = projectDir.parent // We put the publishing version from gradle.properties inside ext. so other // subprojects can access it as well. -extra["publishing_version"] = project.findProperty("VERSION_NAME")?.toString()!! +// Use the determined project version +extra["publishing_version"] = project.version // This is the version of CMake we're requesting to the Android SDK to use. // If missing it will be downloaded automatically. Only CMake versions shipped with the @@ -489,15 +493,25 @@ android { // Used to override the NDK path/version on internal CI or by allowing // users to customize the NDK path/version from their root project (e.g. for Apple Silicon // support) - if (rootProject.hasProperty("ndkPath") && rootProject.properties["ndkPath"] != null) { - ndkPath = rootProject.properties["ndkPath"].toString() - } - if (rootProject.hasProperty("ndkVersion") && rootProject.properties["ndkVersion"] != null) { - ndkVersion = rootProject.properties["ndkVersion"].toString() + val rootProjectNdkPath = rootProject.findProperty("ndkPath")?.toString() + val rootProjectNdkVersion = rootProject.findProperty("ndkVersion")?.toString() + + project.logger.lifecycle("[ReactAndroid] NDK Config: rootProjectNdkPath = '$rootProjectNdkPath'") + project.logger.lifecycle("[ReactAndroid] NDK Config: rootProjectNdkVersion = '$rootProjectNdkVersion'") + project.logger.lifecycle("[ReactAndroid] NDK Config: libs.versions.ndkVersion.get() = '${libs.versions.ndkVersion.get()}'") + + if (!rootProjectNdkPath.isNullOrBlank()) { + project.logger.lifecycle("[ReactAndroid] NDK Config: Using ndkPath from rootProject: '$rootProjectNdkPath'. AGP should infer version. ndkVersion will not be set by this script.") + ndkPath = rootProjectNdkPath + // DO NOT set ndkVersion here. If AGP has a default or another plugin sets it, + // this path-based configuration should ideally take precedence or AGP will use the NDK at this path + // and infer its version. + } else if (!rootProjectNdkVersion.isNullOrBlank()) { + ndkVersion = rootProjectNdkVersion } else { ndkVersion = libs.versions.ndkVersion.get() } - + project.logger.lifecycle("[ReactAndroid] NDK Config: Final applied android.ndkPath='${ndkPath}', android.ndkVersion='${ndkVersion}'") compileOptions { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 @@ -713,12 +727,48 @@ kotlin { tasks.withType { jvmArgs = listOf("-Xshare:off") } /* Publishing Configuration */ -apply(from = "./publish.gradle") - -// We need to override the artifact ID as this project is called `ReactAndroid` but -// the maven coordinates are on `react-android`. -// Please note that the original coordinates, `react-native`, have been voided -// as they caused https://github.com/facebook/react-native/issues/35210 -publishing { - publications { getByName("release", MavenPublication::class) { artifactId = "react-android" } } +// apply(from = "./publish.gradle") // Removed for GitHub Packages publishing + +afterEvaluate { + project.logger.lifecycle("[ReactAndroid] In afterEvaluate: Configuring Maven publishing.") + project.logger.lifecycle("[ReactAndroid] In afterEvaluate: Available publications before configuration: ${publishing.publications.names}") + + publishing { + publications { + // Configure the 'release' publication (created by AGP via android.publishing block) + getByName("release", MavenPublication::class) { + project.logger.lifecycle("[ReactAndroid] In afterEvaluate: Configuring 'release' publication.") + artifactId = "react-android" // Keep original artifactId or change if needed + // groupId and version are inherited from project.group and project.version + pom { + name.set("Aura Patched ReactAndroid") // Customize + description.set("Custom build of ReactAndroid AAR for the Aura project.") // Customize + url.set("https://github.com/isubscribed/react-native") // TODO: Update to your fork's URL + } + } + // Configure the 'debug' publication (created by AGP) + // This is necessary if you want to publish debug variants or if your publish task targets it. + (findByName("debug") as? MavenPublication)?.apply { + project.logger.lifecycle("[ReactAndroid] In afterEvaluate: Configuring 'debug' publication.") + artifactId = "react-android-debug" // Differentiate debug artifactId + pom { + name.set("Aura Patched ReactAndroid (Debug)") // Customize + description.set("Custom debug build of ReactAndroid AAR for the Aura project.") // Customize + url.set("https://github.com/isubscribed/react-native") // TODO: Update to your fork's URL + } + } + } + repositories { + maven { + + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/isubscribed/react-native") // Replace with your fork's owner/repo + credentials { + username = System.getenv("GITHUB_ACTOR") ?: project.findProperty("gpr.user")?.toString() // For local publishing + password = System.getenv("GITHUB_TOKEN") ?: project.findProperty("gpr.key")?.toString() // For local publishing + } + } + } + } + project.logger.lifecycle("[ReactAndroid] In afterEvaluate: Finished configuring Maven publishing.") } From a243fc5e0a37af3231d07dd1efdf01672811482a Mon Sep 17 00:00:00 2001 From: Jay Koutavas Date: Wed, 21 May 2025 13:11:39 -0400 Subject: [PATCH 2/7] checkpoint on local build/publish --- .github/workflows/publish-isubscribed.yml | 1 - .../ReactAndroid/build.gradle.kts | 67 ++++++++++--------- .../react-native/gradle/libs.versions.toml | 2 +- 3 files changed, 36 insertions(+), 34 deletions(-) diff --git a/.github/workflows/publish-isubscribed.yml b/.github/workflows/publish-isubscribed.yml index 1843d8a7a690ba..ae0694ec7b646c 100644 --- a/.github/workflows/publish-isubscribed.yml +++ b/.github/workflows/publish-isubscribed.yml @@ -73,6 +73,5 @@ jobs: # Common Gradle options for CI GRADLE_OPTS: "-Dorg.gradle.daemon=false" run: ./gradlew \ - :packages:react-native:ReactAndroid:publishDebugPublicationToGitHubPackagesRepository \ :packages:react-native:ReactAndroid:publishReleasePublicationToGitHubPackagesRepository \ --info --stacktrace \ No newline at end of file diff --git a/packages/react-native/ReactAndroid/build.gradle.kts b/packages/react-native/ReactAndroid/build.gradle.kts index bd6ece72be72bc..5c6ced0cebff98 100644 --- a/packages/react-native/ReactAndroid/build.gradle.kts +++ b/packages/react-native/ReactAndroid/build.gradle.kts @@ -500,15 +500,19 @@ android { project.logger.lifecycle("[ReactAndroid] NDK Config: rootProjectNdkVersion = '$rootProjectNdkVersion'") project.logger.lifecycle("[ReactAndroid] NDK Config: libs.versions.ndkVersion.get() = '${libs.versions.ndkVersion.get()}'") + // Rely on root project properties (influenced by ANDROID_NDK and libs.versions.toml via root build.gradle) + // Ensure your ANDROID_NDK env var points to NDK 27.0.12077973 + // Ensure libs.versions.toml has ndkVersion = "27.0.12077973" if (!rootProjectNdkPath.isNullOrBlank()) { - project.logger.lifecycle("[ReactAndroid] NDK Config: Using ndkPath from rootProject: '$rootProjectNdkPath'. AGP should infer version. ndkVersion will not be set by this script.") + project.logger.lifecycle("[ReactAndroid] NDK Config: Setting ndkPath from rootProject: '$rootProjectNdkPath'") ndkPath = rootProjectNdkPath - // DO NOT set ndkVersion here. If AGP has a default or another plugin sets it, - // this path-based configuration should ideally take precedence or AGP will use the NDK at this path - // and infer its version. - } else if (!rootProjectNdkVersion.isNullOrBlank()) { - ndkVersion = rootProjectNdkVersion + } + + if (!rootProjectNdkVersion.isNullOrBlank()) { + project.logger.lifecycle("[ReactAndroid] NDK Config: Setting ndkVersion from rootProject: '$rootProjectNdkVersion'") + ndkVersion = libs.versions.ndkVersion.get() } else { + project.logger.lifecycle("[ReactAndroid] NDK Config: Fallback: Setting ndkVersion from libs.versions.toml: '${libs.versions.ndkVersion.get()}'") ndkVersion = libs.versions.ndkVersion.get() } project.logger.lifecycle("[ReactAndroid] NDK Config: Final applied android.ndkPath='${ndkPath}', android.ndkVersion='${ndkVersion}'") @@ -730,45 +734,44 @@ tasks.withType { jvmArgs = listOf("-Xshare:off") } // apply(from = "./publish.gradle") // Removed for GitHub Packages publishing afterEvaluate { - project.logger.lifecycle("[ReactAndroid] In afterEvaluate: Configuring Maven publishing.") - project.logger.lifecycle("[ReactAndroid] In afterEvaluate: Available publications before configuration: ${publishing.publications.names}") - publishing { publications { - // Configure the 'release' publication (created by AGP via android.publishing block) - getByName("release", MavenPublication::class) { - project.logger.lifecycle("[ReactAndroid] In afterEvaluate: Configuring 'release' publication.") - artifactId = "react-android" // Keep original artifactId or change if needed - // groupId and version are inherited from project.group and project.version + // create the "release" publication so you can tweak its coordinates: + create("release") { + from(components.getByName("release")) + artifactId = "react-android" pom { - name.set("Aura Patched ReactAndroid") // Customize - description.set("Custom build of ReactAndroid AAR for the Aura project.") // Customize - url.set("https://github.com/isubscribed/react-native") // TODO: Update to your fork's URL + name.set("Aura Patched ReactAndroid") + description.set("Custom build of ReactAndroid AAR for the Aura project.") + url.set("https://github.com/isubscribed/react-native") } } - // Configure the 'debug' publication (created by AGP) - // This is necessary if you want to publish debug variants or if your publish task targets it. - (findByName("debug") as? MavenPublication)?.apply { - project.logger.lifecycle("[ReactAndroid] In afterEvaluate: Configuring 'debug' publication.") - artifactId = "react-android-debug" // Differentiate debug artifactId - pom { - name.set("Aura Patched ReactAndroid (Debug)") // Customize - description.set("Custom debug build of ReactAndroid AAR for the Aura project.") // Customize - url.set("https://github.com/isubscribed/react-native") // TODO: Update to your fork's URL - } + // if you also want to publish the debug AAR: + create("debug") { + from(components.getByName("debug")) + artifactId = "react-android-debug" + pom { + name.set("Aura Patched ReactAndroid (Debug)") + description.set("Debug build of ReactAndroid AAR for the Aura project.") + url.set("https://github.com/isubscribed/react-native") } + } } repositories { maven { - name = "GitHubPackages" - url = uri("https://maven.pkg.github.com/isubscribed/react-native") // Replace with your fork's owner/repo + url = uri("https://maven.pkg.github.com/isubscribed/react-native") credentials { - username = System.getenv("GITHUB_ACTOR") ?: project.findProperty("gpr.user")?.toString() // For local publishing - password = System.getenv("GITHUB_TOKEN") ?: project.findProperty("gpr.key")?.toString() // For local publishing + username = System.getenv("GITHUB_ACTOR") + password = System.getenv("GITHUB_TOKEN") } } } } - project.logger.lifecycle("[ReactAndroid] In afterEvaluate: Finished configuring Maven publishing.") +} + +tasks.register("printComponents") { + doLast { + components.names.forEach { println(it) } + } } diff --git a/packages/react-native/gradle/libs.versions.toml b/packages/react-native/gradle/libs.versions.toml index 43c8bb3c463e67..664b9d19b16572 100644 --- a/packages/react-native/gradle/libs.versions.toml +++ b/packages/react-native/gradle/libs.versions.toml @@ -4,7 +4,7 @@ minSdk = "24" targetSdk = "35" compileSdk = "35" buildTools = "35.0.0" -ndkVersion = "27.1.12297006" +ndkVersion = "27.0.12077973" # Dependencies versions agp = "8.8.2" androidx-annotation = "1.6.0" From d114ec270c806e4ba431fbdb215d26358f26c568 Mon Sep 17 00:00:00 2001 From: Jay Koutavas Date: Wed, 21 May 2025 13:39:43 -0400 Subject: [PATCH 3/7] checkpoint --- .../ReactAndroid/build.gradle.kts | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/packages/react-native/ReactAndroid/build.gradle.kts b/packages/react-native/ReactAndroid/build.gradle.kts index 5c6ced0cebff98..19986e2fc951e2 100644 --- a/packages/react-native/ReactAndroid/build.gradle.kts +++ b/packages/react-native/ReactAndroid/build.gradle.kts @@ -13,10 +13,12 @@ import de.undercouch.gradle.tasks.download.Download import java.nio.file.Paths import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import org.gradle.api.tasks.bundling.Jar + plugins { + alias(libs.plugins.android.library) id("maven-publish") id("com.facebook.react") - alias(libs.plugins.android.library) alias(libs.plugins.download) alias(libs.plugins.kotlin.android) } @@ -734,11 +736,19 @@ tasks.withType { jvmArgs = listOf("-Xshare:off") } // apply(from = "./publish.gradle") // Removed for GitHub Packages publishing afterEvaluate { + + // ensure the sources‐jar always runs **after** codegen is done + tasks.named("releaseSourcesJar") { + dependsOn("generateCodegenArtifactsFromSchema") + } + tasks.named("debugSourcesJar") { + dependsOn("generateCodegenArtifactsFromSchema") + } + publishing { publications { - // create the "release" publication so you can tweak its coordinates: create("release") { - from(components.getByName("release")) + from(components["release"]) artifactId = "react-android" pom { name.set("Aura Patched ReactAndroid") @@ -746,9 +756,8 @@ afterEvaluate { url.set("https://github.com/isubscribed/react-native") } } - // if you also want to publish the debug AAR: create("debug") { - from(components.getByName("debug")) + from(components["debug"]) artifactId = "react-android-debug" pom { name.set("Aura Patched ReactAndroid (Debug)") @@ -775,3 +784,9 @@ tasks.register("printComponents") { components.names.forEach { println(it) } } } + +tasks.register("printPublications") { + doLast { + println(">>> publications: " + publishing.publications.names) + } +} \ No newline at end of file From 1e578c68cc3c8bc3b381c7a373d92c30921a413e Mon Sep 17 00:00:00 2001 From: Jay Koutavas Date: Wed, 21 May 2025 13:48:56 -0400 Subject: [PATCH 4/7] First successful publication (locally) --- .../ReactAndroid/build.gradle.kts | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/packages/react-native/ReactAndroid/build.gradle.kts b/packages/react-native/ReactAndroid/build.gradle.kts index 19986e2fc951e2..b367811c04e767 100644 --- a/packages/react-native/ReactAndroid/build.gradle.kts +++ b/packages/react-native/ReactAndroid/build.gradle.kts @@ -732,12 +732,18 @@ kotlin { tasks.withType { jvmArgs = listOf("-Xshare:off") } -/* Publishing Configuration */ -// apply(from = "./publish.gradle") // Removed for GitHub Packages publishing +// ----------------------------- +// Publishing Configuration +// ----------------------------- +// Upstream ReactNative ships both release & debug AARs to Maven Central via a top‑level publish.gradle. +// Here, we adapt that flow to push our patched artifacts into our GitHub Packages fork. -afterEvaluate { +// We removed the generic publish.gradle include, opting for an in‑place Kotlin DSL block +// that binds our build artifacts to GitHub Packages. - // ensure the sources‐jar always runs **after** codegen is done +afterEvaluate { + // 1) Ensure codegen-generated sources are packaged into the sources JAR + // (releaseSourcesJar / debugSourcesJar rely on generated code under build/generated/source/codegen) tasks.named("releaseSourcesJar") { dependsOn("generateCodegenArtifactsFromSchema") } @@ -747,7 +753,9 @@ afterEvaluate { publishing { publications { + // 2) Mirror upstream: publish both release and debug components create("release") { + // Attach the AAR output created by AGP for the 'release' buildType from(components["release"]) artifactId = "react-android" pom { @@ -757,6 +765,7 @@ afterEvaluate { } } create("debug") { + // Attach the debug AAR as an optional artifact from(components["debug"]) artifactId = "react-android-debug" pom { @@ -768,17 +777,26 @@ afterEvaluate { } repositories { maven { + // Push to your fork's GitHub Packages registry name = "GitHubPackages" url = uri("https://maven.pkg.github.com/isubscribed/react-native") credentials { - username = System.getenv("GITHUB_ACTOR") - password = System.getenv("GITHUB_TOKEN") + // try a project property first (so you can set -Pgpr.user=foo locally), + // then fall back to the GitHub Actions env + username = (project.findProperty("gpr.user") as String?) + ?: System.getenv("GITHUB_ACTOR") + password = (project.findProperty("gpr.key") as String?) + ?: System.getenv("GITHUB_TOKEN") } } } } } +/********************** + * Some utility tasks + **********************/ + tasks.register("printComponents") { doLast { components.names.forEach { println(it) } From a1bd126196fb0dacfb0d844eb624f3a8fae99a8a Mon Sep 17 00:00:00 2001 From: Jay Koutavas Date: Wed, 21 May 2025 16:22:54 -0400 Subject: [PATCH 5/7] We got a consumable aar published locally --- .github/workflows/publish-isubscribed.yml | 4 +--- packages/react-native/ReactAndroid/build.gradle.kts | 12 +----------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/.github/workflows/publish-isubscribed.yml b/.github/workflows/publish-isubscribed.yml index ae0694ec7b646c..4149360ada3513 100644 --- a/.github/workflows/publish-isubscribed.yml +++ b/.github/workflows/publish-isubscribed.yml @@ -72,6 +72,4 @@ jobs: ANDROID_NDK_LATEST_PATH: ${{ steps.setup-ndk.outputs.ndk-path }} # nttld/setup-ndk provides this output # Common Gradle options for CI GRADLE_OPTS: "-Dorg.gradle.daemon=false" - run: ./gradlew \ - :packages:react-native:ReactAndroid:publishReleasePublicationToGitHubPackagesRepository \ - --info --stacktrace \ No newline at end of file + run: ./gradlew :packages:react-native:ReactAndroid:publishReleasePublicationToGitHubPackagesRepository \ No newline at end of file diff --git a/packages/react-native/ReactAndroid/build.gradle.kts b/packages/react-native/ReactAndroid/build.gradle.kts index b367811c04e767..289677aa0dd08f 100644 --- a/packages/react-native/ReactAndroid/build.gradle.kts +++ b/packages/react-native/ReactAndroid/build.gradle.kts @@ -28,7 +28,7 @@ version = project.findProperty("libraryVersion")?.toString() ?: project.findProperty("VERSION_NAME")?.toString() ?: "0.0.0-SNAPSHOT" -group = "com.github.isubscribed" // Your GitHub Packages group ID +group = "com.facebook.react" // 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. @@ -764,16 +764,6 @@ afterEvaluate { url.set("https://github.com/isubscribed/react-native") } } - create("debug") { - // Attach the debug AAR as an optional artifact - from(components["debug"]) - artifactId = "react-android-debug" - pom { - name.set("Aura Patched ReactAndroid (Debug)") - description.set("Debug build of ReactAndroid AAR for the Aura project.") - url.set("https://github.com/isubscribed/react-native") - } - } } repositories { maven { From 367732f6bac55ee2a85e16fc07a901dc1b7244a1 Mon Sep 17 00:00:00 2001 From: Jay Koutavas Date: Thu, 22 May 2025 16:32:23 -0400 Subject: [PATCH 6/7] We're not going to bother with having the ci pipeline do the builds. We'll do them locally with: ./gradlew \ :packages:react-native:ReactAndroid:publishReleasePublicationToGitHubPackagesRepository \ :packages:react-native:ReactAndroid:publishDebugPublicationToGitHubPackagesRepository --- .github/workflows/publish-isubscribed.yml | 75 ------------------- .../ReactAndroid/build.gradle.kts | 25 ++++--- 2 files changed, 16 insertions(+), 84 deletions(-) delete mode 100644 .github/workflows/publish-isubscribed.yml diff --git a/.github/workflows/publish-isubscribed.yml b/.github/workflows/publish-isubscribed.yml deleted file mode 100644 index 4149360ada3513..00000000000000 --- a/.github/workflows/publish-isubscribed.yml +++ /dev/null @@ -1,75 +0,0 @@ -name: Publish ReactAndroid AAR to GitHub Packages - -on: - push: - tags: - - 'v*' # Trigger publishing when a tag like v1.0.0, v0.2.1 is pushed - -jobs: - publish-aar: - name: Publish ReactAndroid AAR - runs-on: ubuntu-latest - permissions: - contents: read # To checkout the repository - packages: write # To publish packages to GitHub Packages - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Fetches all history, useful for versioning or changelogs - - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'temurin' - - - name: Set up NDK - uses: nttld/setup-ndk@v1 - id: setup-ndk - with: - # Specify the NDK version your ReactAndroid build requires. - # This should match the version that was causing CXX1100 errors if not aligned. - ndk-version: r27 # Example for NDK 27. Adjust if 27.0.12077973 is r27 or a specific r2X version. Check nttld/setup-ndk docs for exact version string. - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: '18.x' # Use a Node.js LTS version compatible with your RN version - - - name: Install Yarn - run: npm install -g yarn - - - name: Install JavaScript dependencies - # This step is crucial if your ReactAndroid build relies on codegen or other JS tooling. - # Adjust working-directory if your main package.json/yarn.lock is not in './packages/react-native'. - # If your JS project root is the repository root, you can remove `working-directory`. - run: yarn install --frozen-lockfile - working-directory: ./packages/react-native - - - name: Validate Gradle wrapper - uses: gradle/wrapper-validation-action@v2 - - - name: Setup Gradle - # This action also handles caching Gradle dependencies for faster builds. - uses: gradle/actions/setup-gradle@v3 - - - name: Get version from tag - id: get_version - # Extracts the version number from the tag (e.g., v1.2.3 -> 1.2.3) - # If your tags don't have a 'v' prefix, use: echo "VERSION=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT - run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT - - - name: Publish ReactAndroid AAR to GitHub Packages - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_ACTOR: ${{ github.actor }} - # This property name 'libraryVersion' should match what you use in your - # ReactAndroid/build.gradle.kts (e.g., project.property("libraryVersion") or rootProject.extra["libraryVersion"]) - ORG_GRADLE_PROJECT_libraryVersion: ${{ steps.get_version.outputs.VERSION }} - # Pass the NDK path to Gradle. Your build.gradle.kts should be configured to use this. - ANDROID_NDK_LATEST_PATH: ${{ steps.setup-ndk.outputs.ndk-path }} # nttld/setup-ndk provides this output - # Common Gradle options for CI - GRADLE_OPTS: "-Dorg.gradle.daemon=false" - run: ./gradlew :packages:react-native:ReactAndroid:publishReleasePublicationToGitHubPackagesRepository \ No newline at end of file diff --git a/packages/react-native/ReactAndroid/build.gradle.kts b/packages/react-native/ReactAndroid/build.gradle.kts index 289677aa0dd08f..e6faf5b76c962c 100644 --- a/packages/react-native/ReactAndroid/build.gradle.kts +++ b/packages/react-native/ReactAndroid/build.gradle.kts @@ -23,13 +23,6 @@ plugins { alias(libs.plugins.kotlin.android) } -// Use 'libraryVersion' property for CI/command-line, fallback to VERSION_NAME, then SNAPSHOT -version = project.findProperty("libraryVersion")?.toString() - ?: project.findProperty("VERSION_NAME")?.toString() - ?: "0.0.0-SNAPSHOT" - -group = "com.facebook.react" - // 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. // After that we build native code from src/main/jni with module path pointing at third-party-ndk. @@ -751,16 +744,30 @@ afterEvaluate { dependsOn("generateCodegenArtifactsFromSchema") } + group = "com.facebook.react" + version = "0.79.2" publishing { publications { // 2) Mirror upstream: publish both release and debug components create("release") { - // Attach the AAR output created by AGP for the 'release' buildType from(components["release"]) + groupId = "com.facebook.react" artifactId = "react-android" + version = "0.79.2" pom { name.set("Aura Patched ReactAndroid") - description.set("Custom build of ReactAndroid AAR for the Aura project.") + description.set("Release build of ReactAndroid AAR for the Aura project.") + url.set("https://github.com/isubscribed/react-native") + } + } + create("debug") { + from(components["debug"]) + groupId = "com.facebook.react" + artifactId = "react-android-debug" + version = "0.79.2" + pom { + name.set("Aura Patched ReactAndroid (Debug)") + description.set("Debug build of ReactAndroid AAR for the Aura project.") url.set("https://github.com/isubscribed/react-native") } } From 32f3f0de29ea1d8dd0574f64ab13d1e8b0549fa6 Mon Sep 17 00:00:00 2001 From: Jay Koutavas Date: Tue, 27 May 2025 09:42:49 -0400 Subject: [PATCH 7/7] Remove duplicate code gen --- packages/react-native/ReactAndroid/build.gradle.kts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/react-native/ReactAndroid/build.gradle.kts b/packages/react-native/ReactAndroid/build.gradle.kts index e6faf5b76c962c..796438bc01600f 100644 --- a/packages/react-native/ReactAndroid/build.gradle.kts +++ b/packages/react-native/ReactAndroid/build.gradle.kts @@ -735,13 +735,11 @@ tasks.withType { jvmArgs = listOf("-Xshare:off") } // that binds our build artifacts to GitHub Packages. afterEvaluate { - // 1) Ensure codegen-generated sources are packaged into the sources JAR - // (releaseSourcesJar / debugSourcesJar rely on generated code under build/generated/source/codegen) - tasks.named("releaseSourcesJar") { - dependsOn("generateCodegenArtifactsFromSchema") - } - tasks.named("debugSourcesJar") { - dependsOn("generateCodegenArtifactsFromSchema") + // make sure both sources-jar tasks wait for codegen + listOf("releaseSourcesJar", "debugSourcesJar").forEach { name -> + tasks.named(name) { + dependsOn("generateCodegenArtifactsFromSchema") + } } group = "com.facebook.react"