Skip to content

Commit 16a1c2a

Browse files
coadofacebook-github-bot
authored andcommitted
Publish Static Hermes Artifacts to Maven (#1765)
Summary: Pull Request resolved: #1765 This diff configures publishing Static Hermes artifacts to Maven to `com.facebook.hermes-v2` coordinates. The logic is the same as in Hermes publishing workflow (realeses, commitlies). Differential Revision: D80450523
1 parent 32aa433 commit 16a1c2a

File tree

18 files changed

+786
-29
lines changed

18 files changed

+786
-29
lines changed

.github/workflows/build-android.yml

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
name: build-android
22

3-
on: workflow_call
3+
on:
4+
workflow_call:
5+
inputs:
6+
release-type:
7+
required: true
8+
description: The type of release we are building. It could be commitly, release or dry-run
9+
type: string
410

511
jobs:
612
build-android:
@@ -19,18 +25,26 @@ jobs:
1925
steps:
2026
- name: Checkout
2127
uses: actions/checkout@v4
22-
- name: Build Hermes Compiler
23-
run: |-
24-
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
25-
# Build the Hermes compiler so that the cross compiler build can
26-
# access it to build the VM
27-
cmake --build ./build --target hermesc -j 4
28+
- name: Setup node.js
29+
uses: ./.github/actions/setup-node
30+
- name: Install node dependencies
31+
uses: ./.github/actions/yarn-install
32+
- name: Set React Native Version
33+
shell: bash
34+
run: node ./utils/scripts/hermes/set-artifacts-version.js --build-type ${{ inputs.release-type }}
2835
- name: Build android
2936
shell: bash
3037
run: |
3138
cd android
32-
TASKS="publishAllToMavenTempLocal build"
33-
./gradlew $TASKS
39+
40+
if [[ "${{ inputs.release-type }}" == "commitly" ]]; then
41+
export ORG_GRADLE_PROJECT_isSnapshot="true"
42+
TASKS="publishAndroidOnlyToMavenTempLocal publishAndroidOnlyToSonatype :build"
43+
else
44+
TASKS="publishAllToMavenTempLocal :build"
45+
fi
46+
47+
./gradlew $TASKS -PenableWarningsAsErrors=true
3448
- name: Upload Maven Artifacts
3549
uses: actions/upload-artifact@v4.3.4
3650
with:

.github/workflows/publish.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: publish
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
release-type:
7+
required: true
8+
description: The type of release we are building. It could be release or dry-run
9+
type: string
10+
11+
jobs:
12+
publish:
13+
runs-on: 8-core-ubuntu
14+
container:
15+
image: reactnativecommunity/react-native-android:latest
16+
env:
17+
TERM: "dumb"
18+
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
19+
env:
20+
HERMES_WS_DIR: /tmp/hermes
21+
ORG_GRADLE_PROJECT_SIGNING_PWD: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_PWD }}
22+
ORG_GRADLE_PROJECT_SIGNING_KEY: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_KEY }}
23+
ORG_GRADLE_PROJECT_SONATYPE_USERNAME: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_USERNAME }}
24+
ORG_GRADLE_PROJECT_SONATYPE_PASSWORD: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_PASSWORD }}
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
- name: Setup git safe folders
29+
shell: bash
30+
run: git config --global --add safe.directory '*'
31+
- name: Create /tmp/hermes/osx-bin directory
32+
shell: bash
33+
run: mkdir -p /tmp/hermes/osx-bin
34+
- name: Download osx-bin release artifacts
35+
uses: actions/download-artifact@v4
36+
with:
37+
name: hermes-osx-bin-Release
38+
path: /tmp/hermes/osx-bin/Release
39+
- name: Download osx-bin debug artifacts
40+
uses: actions/download-artifact@v4
41+
with:
42+
name: hermes-osx-bin-Debug
43+
path: /tmp/hermes/osx-bin/Debug
44+
- name: Download darwin-bin release artifacts
45+
uses: actions/download-artifact@v4
46+
with:
47+
name: hermes-darwin-bin-Release
48+
path: /tmp/hermes/hermes-runtime-darwin
49+
- name: Download darwin-bin debug artifacts
50+
uses: actions/download-artifact@v4
51+
with:
52+
name: hermes-darwin-bin-Debug
53+
path: /tmp/hermes/hermes-runtime-darwin
54+
- name: Download hermes dSYM debug artifacts
55+
uses: actions/download-artifact@v4
56+
with:
57+
name: hermes-dSYM-Debug
58+
path: /tmp/hermes/dSYM/Debug
59+
- name: Download hermes dSYM release vartifacts
60+
uses: actions/download-artifact@v4
61+
with:
62+
name: hermes-dSYM-Release
63+
path: /tmp/hermes/dSYM/Release
64+
- name: Download linux-bin artifacts
65+
uses: actions/download-artifact@v4
66+
with:
67+
name: hermes-linux-bin
68+
path: /tmp/hermes/linux64-bin
69+
- name: Show /tmp/hermes directory
70+
shell: bash
71+
run: ls -lR /tmp/hermes
72+
- name: Copy Hermes binaries
73+
shell: bash
74+
run: |
75+
mkdir -p ./android/ios-artifacts/artifacts/
76+
cp $HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-Debug.tar.gz ./android/ios-artifacts/artifacts/hermes-ios-debug.tar.gz
77+
cp $HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-Release.tar.gz ./android/ios-artifacts/artifacts/hermes-ios-release.tar.gz
78+
cp $HERMES_WS_DIR/dSYM/Debug/hermes.framework.dSYM ./android/ios-artifacts/artifacts/hermes-framework-dSYM-debug.tar.gz
79+
cp $HERMES_WS_DIR/dSYM/Release/hermes.framework.dSYM ./android/ios-artifacts/artifacts/hermes-framework-dSYM-release.tar.gz
80+
- name: Print Artifacts Directory
81+
shell: bash
82+
run: ls -lR ./android/ios-artifacts/artifacts/
83+
- name: Setup node.js
84+
uses: ./.github/actions/setup-node
85+
- name: Install dependencies
86+
uses: ./.github/actions/yarn-install
87+
- name: Publish artifacts
88+
shell: bash
89+
run: |
90+
node ./utils/scripts/hermes/publish-artifacts.js -t ${{ inputs.release-type }}

.github/workflows/rn-build-hermes.yml

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,48 @@
11
name: RN Build Static Hermes
22

33
on:
4+
workflow_dispatch:
5+
inputs:
6+
release-type:
7+
description: 'Release type (release, commitly, dry-run)'
8+
required: false
9+
default: 'dry-run'
410
pull_request:
511
push:
612
branches:
7-
- main
13+
- static_h
814

915
jobs:
16+
set_release_type:
17+
runs-on: ubuntu-latest
18+
if: github.repository == 'facebook/hermes'
19+
outputs:
20+
RELEASE_TYPE: ${{ steps.set_release_type.outputs.RELEASE_TYPE }}
21+
env:
22+
EVENT_NAME: ${{ github.event_name }}
23+
REF: ${{ github.ref }}
24+
steps:
25+
set_release_type:
26+
runs-on: ubuntu-latest
27+
if: github.repository == 'facebook/hermes'
28+
outputs:
29+
RELEASE_TYPE: ${{ steps.set_release_type.outputs.RELEASE_TYPE }}
30+
env:
31+
EVENT_NAME: ${{ github.event_name }}
32+
REF: ${{ github.ref }}
33+
steps:
34+
- id: set_release_type
35+
run: |
36+
if [[ $EVENT_NAME == "push" && $REF == refs/heads/static_h ]]; then
37+
echo "Setting release type to commitly"
38+
echo "RELEASE_TYPE=commitly" >> $GITHUB_OUTPUT
39+
elif [[ $EVENT_NAME == "workflow_dispatch" ]]; then
40+
echo "Setting release type to ${{ github.event.inputs.release-type }}"
41+
echo "RELEASE_TYPE=${{ github.event.inputs.release-type }}" >> $GITHUB_OUTPUT
42+
else
43+
echo "Setting release type to dry-run"
44+
echo "RELEASE_TYPE=dry-run" >> $GITHUB_OUTPUT
45+
fi
1046
build_hermesc_apple:
1147
uses: ./.github/workflows/build-hermesc-apple.yml
1248
build_apple_slices_hermes:
@@ -21,4 +57,17 @@ jobs:
2157
uses: ./.github/workflows/build-hermesc-windows.yml
2258
build_android:
2359
uses: ./.github/workflows/build-android.yml
60+
needs: set_release_type
2461
secrets: inherit
62+
with:
63+
release-type: ${{ needs.set_release_type.outputs.RELEASE_TYPE }}
64+
publish:
65+
uses: ./.github/workflows/publish.yml
66+
needs:
67+
[
68+
set_release_type,
69+
build_hermes_macos,
70+
build_hermesc_linux,
71+
]
72+
with:
73+
release-type: ${{ needs.set_release_type.outputs.RELEASE_TYPE }}

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ endif()
6565
# - npm/package.json
6666
# - hermes-engine.podspec
6767
project(Hermes
68-
VERSION 0.12.0
68+
VERSION 2.0.0
6969
LANGUAGES C CXX)
7070

7171
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/")

android/build-logic/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ repositories {
1212
gradlePluginPortal()
1313
}
1414

15-
group = "com.facebook.hermes"
15+
group = "com.facebook.hermes-v2"
1616

1717
kotlin {
1818
@Suppress("MagicNumber") jvmToolchain(17)

android/build-logic/src/main/kotlin/com/facebook/hermes/plugins/internal/TestUtilsPlugin.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,16 @@ class HermesUtils(private val project: Project) {
4040
val candidateHermesCPaths =
4141
listOf(
4242
"$hermesWs/build/ImportHostCompilers.cmake",
43-
"$hermesWs/build_release/ImportHostCompilers.cmake")
43+
"$hermesWs/build_release/ImportHostCompilers.cmake",
44+
)
4445

45-
return candidateHermesCPaths.lastOrNull { File(it).exists() }
46-
?: throw InvalidUserDataException("Hermes host build not found")
46+
val hermesCPath = candidateHermesCPaths.lastOrNull { File(it).exists() }
47+
if (hermesCPath == null) {
48+
project.logger.warn("Could not find hermesC path. Using default path.")
49+
return "$hermesWs/build/ImportHostCompilers.cmake"
50+
}
51+
52+
return hermesCPath
4753
}
4854

4955
// For Facebook internal use:

android/build-logic/src/main/kotlin/publish.gradle.kts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ plugins {
1010
id("signing")
1111
}
1212

13+
val isSnapshot: Boolean = findProperty("isSnapshot")?.toString()?.toBoolean() ?: false
1314
val signingKey: String? = findProperty("SIGNING_KEY")?.toString()
1415
val signingPwd: String? = findProperty("SIGNING_PWD")?.toString()
1516

@@ -19,16 +20,24 @@ publishing {
1920
publications {
2021
create<MavenPublication>("release") {
2122
afterEvaluate {
22-
from(components["default"])
23-
version = project.version.toString()
23+
if (project.plugins.hasPlugin("com.android.library")) {
24+
from(components["default"])
25+
}
26+
27+
version =
28+
if (isSnapshot) {
29+
"${project.version}-SNAPSHOT"
30+
} else {
31+
project.version.toString()
32+
}
33+
2434
groupId = project.group.toString()
25-
artifactId = "hermes-android"
2635
}
2736

2837
pom {
2938
name.set("hermes")
3039
description.set("A JavaScript engine optimized for fast start-up of React Native apps")
31-
url.set("https://github.com/facebook/hermes")
40+
url.set("https://github.com/facebook/hermes/tree/static_h")
3241

3342
developers {
3443
developer {

android/build.gradle.kts

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,32 @@ import org.apache.tools.ant.taskdefs.condition.Os
1111
plugins {
1212
id("maven-publish")
1313
id("signing")
14+
alias(libs.plugins.nexus.publish)
1415
alias(libs.plugins.android.library)
1516
alias(libs.plugins.download)
1617
id("publish")
1718
}
1819

19-
group = "com.facebook.hermes"
20+
group = "com.facebook.hermes-v2"
2021

2122
version = project.findProperty("VERSION_NAME")?.toString()!!
2223

2324
val cmakeVersion = System.getenv("CMAKE_VERSION") ?: libs.versions.cmake.get()
2425
val cmakePath = "${getSDKPath()}/cmake/$cmakeVersion"
2526
val cmakeBinaryPath = "${cmakePath}/bin/cmake"
27+
val sonatypeUsername = findProperty("SONATYPE_USERNAME")?.toString()
28+
val sonatypePassword = findProperty("SONATYPE_PASSWORD")?.toString()
29+
30+
nexusPublishing {
31+
repositories {
32+
sonatype {
33+
username.set(sonatypeUsername)
34+
password.set(sonatypePassword)
35+
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
36+
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
37+
}
38+
}
39+
}
2640

2741
fun getSDKPath(): String {
2842
val androidSdkRoot = System.getenv("ANDROID_SDK_ROOT")
@@ -50,9 +64,12 @@ fun getSDKManagerPath(): String {
5064
}
5165
}
5266

53-
val buildDir = project.layout.buildDirectory.get().asFile
5467
val hermesDir = project.projectDir.parentFile
55-
val hermesBuildDir = File("$buildDir/hermes")
68+
val hermesBuildDir = File("$hermesDir/build")
69+
70+
project.layout.buildDirectory.set(hermesBuildDir)
71+
72+
val buildDir = project.layout.buildDirectory.get().asFile
5673
val hermesCOutputBinary = File("$buildDir/hermes/bin/hermesc")
5774

5875
// This filetree represents the file of the Hermes build that we want as input/output
@@ -77,7 +94,8 @@ val installCMake by
7794
tasks.registering(CustomExecTask::class) {
7895
onlyIfProvidedPathDoesNotExists.set(cmakePath)
7996
commandLine(
80-
windowsAwareCommandLine(getSDKManagerPath(), "--install", "cmake;${cmakeVersion}"))
97+
windowsAwareCommandLine(getSDKManagerPath(), "--install", "cmake;${cmakeVersion}")
98+
)
8199
}
82100

83101
val configureBuildForHermes by
@@ -99,7 +117,8 @@ val configureBuildForHermes by
99117
"-B",
100118
hermesBuildDir.toString(),
101119
"-DJSI_DIR=" + jsiDir.absolutePath,
102-
"-DCMAKE_BUILD_TYPE=Debug")
120+
"-DCMAKE_BUILD_TYPE=Debug",
121+
)
103122
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
104123
cmakeCommandLine = cmakeCommandLine + "-GNMake Makefiles"
105124
}
@@ -207,7 +226,8 @@ android {
207226
"-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=True",
208227
// We intentionally build Hermes with Intl support only. This is to simplify
209228
// the build setup and to avoid overcomplicating the build-type matrix.
210-
"-DHERMES_ENABLE_INTL=True")
229+
"-DHERMES_ENABLE_INTL=True",
230+
)
211231

212232
targets("hermesvm")
213233
}
@@ -291,3 +311,15 @@ tasks.withType<JavaCompile>().configureEach {
291311
options.compilerArgs.add("-Xlint:deprecation,unchecked")
292312
options.compilerArgs.add("-Werror")
293313
}
314+
315+
tasks.register("publishAndroidOnlyToMavenTempLocal") {
316+
dependsOn(":publishAllPublicationsToMavenTempLocalRepository", ":build")
317+
}
318+
319+
tasks.register("publishAndroidOnlyToSonatype") { dependsOn(":publishToSonatype") }
320+
321+
// We need to override the artifact ID as this project is called `hermes-engine` but
322+
// the maven coordinates are on `hermes-android`.
323+
publishing {
324+
publications { getByName("release", MavenPublication::class) { artifactId = "hermes-android" } }
325+
}

android/gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ download = "5.4.0"
1414
fbjni = "0.7.0"
1515
kotlin = "2.1.20"
1616
ktfmt = "0.22.0"
17+
nexus-publish = "2.0.0"
1718
yoga-proguard-annotations = "1.19.0"
1819

1920
[libraries]
@@ -25,4 +26,5 @@ yoga-proguard-annotations = { module = "com.facebook.yoga:proguard-annotations",
2526
android-library = { id = "com.android.library", version.ref = "agp" }
2627
download = { id = "de.undercouch.download", version.ref = "download" }
2728
ktfmt = { id = "com.ncorti.ktfmt.gradle", version.ref = "ktfmt" }
29+
nexus-publish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexus-publish" }
2830
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }

0 commit comments

Comments
 (0)