Skip to content

Commit e8b7591

Browse files
committed
chore(tools/rntv-workflows): refactor CI workflows for TV (react-native-tvos#1110)
This refactors the CI workflow for both main and release branches. Semantically different parts of the builds are broken out into different build jobs - Maven artifact jobs - RNTester jobs depend on Maven artifact jobs - NPM package jobs depend on all previous jobs being successful Concurrency added to the workflows to cancel stale jobs when new commits are added
1 parent 02d4371 commit e8b7591

9 files changed

Lines changed: 368 additions & 302 deletions
Lines changed: 9 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
build:
2-
name: Build Android artifacts for a release
2+
name: Build Android Maven artifacts
33
steps:
44
- eas/checkout
55
- eas/install_node_modules
6-
- run:
7-
name: Patch @microsoft/api-extractor
8-
working_directory: ../..
9-
command: |
10-
patch -p1 < ./tools/rntv-workflows/microsoft-api-extractor.patch
116
- run:
127
name: Set up build-specific environment
138
working_directory: ../..
@@ -17,23 +12,20 @@ build:
1712
export ANDROID_CUSTOM_SDKMANAGER_PATH=`which sdkmanager`
1813
echo "ANDROID_CUSTOM_SDKMANAGER_PATH: $ANDROID_CUSTOM_SDKMANAGER_PATH"
1914
set-env ANDROID_CUSTOM_SDKMANAGER_PATH $ANDROID_CUSTOM_SDKMANAGER_PATH
20-
# Location for NPM tarballs
21-
export NPM_TARBALL_LOCATION=$PWD/npm-tarballs
22-
mkdir -p $NPM_TARBALL_LOCATION
23-
set-env NPM_TARBALL_LOCATION $NPM_TARBALL_LOCATION
24-
# Location for RNTester APKs
25-
export RNTESTER_APK_LOCATION=$PWD/RNTester-Android
26-
mkdir -p $RNTESTER_APK_LOCATION/Debug
27-
mkdir -p $RNTESTER_APK_LOCATION/Release
28-
set-env RNTESTER_APK_LOCATION $RNTESTER_APK_LOCATION
15+
# Install cmake
16+
echo "Installing CMake 3.30.5..."
17+
sdkmanager --install "cmake;3.30.5"
2918
# Root directory
3019
export ROOT_DIR=$PWD
3120
set-env ROOT_DIR $ROOT_DIR
3221
if [[ "$RNTV_RELEASE_BUILD" != "1" ]]; then
33-
echo "Use hermes nightly build..."
34-
node ./scripts/releases/use-hermes-nightly.js
22+
. ./tools/rntv-workflows/override-nightly-build-version.sh
23+
echo "Hermes build from nightly build: $REACT_NATIVE_OVERRIDE_NIGHTLY_BUILD_VERSION"
24+
set-env REACT_NATIVE_OVERRIDE_NIGHTLY_BUILD_VERSION $REACT_NATIVE_OVERRIDE_NIGHTLY_BUILD_VERSION
25+
# node ./scripts/releases/use-hermes-nightly.js
3526
yarn
3627
set-env HERMES_VERSION nightly
28+
set-env RN_DEP_VERSION nightly
3729
fi
3830
- run:
3931
name: Copy and modify publish.gradle
@@ -58,49 +50,12 @@ build:
5850
working_directory: ../..
5951
command: |
6052
./gradlew publishAllToMavenTempLocal
61-
- run:
62-
name: Run Typescript generation
63-
working_directory: ../..
64-
command: |
65-
if [[ "$RNTV_RELEASE_BUILD" != "1" ]]; then
66-
yarn build-types
67-
fi
68-
- run:
69-
name: Create virtualized-lists tarball
70-
working_directory: ../../packages/virtualized-lists
71-
command: |
72-
npm pack --pack-destination $ROOT_DIR
73-
- run:
74-
name: Create react-native tarball
75-
working_directory: ../../packages/react-native
76-
command: |
77-
npm pack --pack-destination $ROOT_DIR
78-
- run:
79-
name: Build RNTester app for Android and Android TV (Debug)
80-
working_directory: ../../packages/rn-tester
81-
command: |
82-
echo "Building RNTester..."
83-
yarn build-android-hermes
84-
echo "Copying RNTester APKs to $RNTESTER_APK_LOCATION..."
85-
cp -r android/app/build/outputs/apk/debug/* $RNTESTER_APK_LOCATION/Debug
86-
echo "Build completed."
87-
- run:
88-
name: Build RNTester app for Android and Android TV (Release)
89-
working_directory: ../../packages/rn-tester
90-
command: |
91-
echo "Building RNTester..."
92-
yarn build-android-hermes-release
93-
echo "Copying RNTester APKs to $RNTESTER_APK_LOCATION..."
94-
cp -r android/app/build/outputs/apk/release/* $RNTESTER_APK_LOCATION/Release
95-
echo "Build completed."
9653
- run:
9754
name: Package Android artifacts
9855
working_directory: ../..
9956
command: |
10057
export REACT_NATIVE_VERSION=`npx tsx tools/rntv-workflows/src/get-react-native-version.ts`
10158
echo "REACT_NATIVE_VERSION: $REACT_NATIVE_VERSION"
102-
(cd RNTester-Android/Debug; tar zcf $ROOT_DIR/rntester-$REACT_NATIVE_VERSION-androidtv-debug.tgz *)
103-
(cd RNTester-Android/Release; tar zcf $ROOT_DIR/rntester-$REACT_NATIVE_VERSION-androidtv-release.tgz *)
10459
(cd maven-local; tar zcf $ROOT_DIR/react-android-hermes-$REACT_NATIVE_VERSION.tgz *)
10560
- run:
10661
name: Send Android artifacts to Sonatype
@@ -118,5 +73,3 @@ build:
11873
type: build-artifact
11974
path: |
12075
react-android-hermes-*.tgz
121-
rntester-*.tgz
122-
react-native-*.tgz

tools/rntv-workflows/.eas/build/build-rncore-apple.yml renamed to tools/rntv-workflows/.eas/build/build-apple-artifacts.yml

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ build:
8686
tar zcf $MAVEN_ARTIFACTS_PATH/ReactCoreDebug.framework.dSYM.tar.gz *
8787
echo "RNCore Debug framework tarball created."
8888
- run:
89-
name: RNCore prebuild (Release)
89+
name: Build RNCore framework (Release)
9090
working_directory: ../../packages/react-native
9191
command: |
9292
node scripts/ios-prebuild -s -f Release
@@ -120,52 +120,12 @@ build:
120120
command: |
121121
echo "Publishing react-native-artifacts to Maven local repository..."
122122
./gradlew :packages:react-native:ReactAndroid:external-artifacts:publishAllPublicationsToMavenTempLocalRepository
123-
- run:
124-
name: Build RNTester for iOS using RNCore artifacts
125-
working_directory: ../../packages/rn-tester
126-
command: |
127-
. ../../tools/rntv-workflows/ruby-env.sh
128-
mkdir $ROOT_DIR/RNTester-iOS
129-
export RCT_USE_RN_DEP=1
130-
export RCT_USE_PREBUILT_RNCORE=1
131-
export RNTV_TESTONLY_LOCAL_RNCORE_REPOSITORY=file://$ROOT_DIR/maven-local
132-
echo "Building RNTester..."
133-
echo "Cleaning build directories..."
134-
yarn clean-ios
135-
echo "Setting up RNTester..."
136-
yarn setup-ios-hermes
137-
echo "Building RNTester..."
138-
yarn build-ios-hermes
139-
echo "Build completed."
140-
cp -r $ROOT_DIR/packages/rn-tester/build/Build/Products/Debug-iphonesimulator/RNTester.app $ROOT_DIR/RNTester-iOS
141-
cp -r $ROOT_DIR/packages/rn-tester/build/Build/Products/Debug-iphonesimulator/RNTester.app.dSYM $ROOT_DIR/RNTester-iOS
142-
- run:
143-
name: Build RNTester for tvOS using RNCore artifacts
144-
working_directory: ../../packages/rn-tester
145-
command: |
146-
. ../../tools/rntv-workflows/ruby-env.sh
147-
mkdir $ROOT_DIR/RNTester-tvOS
148-
export RCT_USE_RN_DEP=1
149-
export RCT_USE_PREBUILT_RNCORE=1
150-
export RNTV_TESTONLY_LOCAL_RNCORE_REPOSITORY=file://$ROOT_DIR/maven-local
151-
echo "Building RNTester..."
152-
echo "Cleaning build directories..."
153-
yarn clean-ios
154-
echo "Setting up RNTester..."
155-
yarn setup-tvos-hermes
156-
echo "Building RNTester..."
157-
yarn build-tvos-hermes
158-
echo "Build completed."
159-
cp -r $ROOT_DIR/packages/rn-tester/build/Build/Products/Debug-appletvsimulator/RNTester.app $ROOT_DIR/RNTester-tvOS
160-
cp -r $ROOT_DIR/packages/rn-tester/build/Build/Products/Debug-appletvsimulator/RNTester.app.dSYM $ROOT_DIR/RNTester-tvOS
161123
- run:
162124
name: Package Apple artifacts
163125
working_directory: ../..
164126
command: |
165127
export REACT_NATIVE_VERSION=`npx tsx tools/rntv-workflows/src/get-react-native-version.ts`
166128
echo "REACT_NATIVE_VERSION: $REACT_NATIVE_VERSION"
167-
(cd RNTester-iOS; tar zcf $ROOT_DIR/rntester-$REACT_NATIVE_VERSION-iphone.tgz *)
168-
(cd RNTester-tvOS; tar zcf $ROOT_DIR/rntester-$REACT_NATIVE_VERSION-appletv.tgz *)
169129
(cd maven-local; tar zcf $ROOT_DIR/react-native-artifacts-$REACT_NATIVE_VERSION.tgz *)
170130
- run:
171131
name: Send Apple artifacts to Sonatype
@@ -183,5 +143,4 @@ build:
183143
type: build-artifact
184144
path: |
185145
react-native-artifacts-*.tgz
186-
rntester-*.tgz
187146
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
build:
2+
name: Build Android artifacts for a release
3+
steps:
4+
- eas/checkout
5+
- eas/install_node_modules
6+
- run:
7+
name: Patch @microsoft/api-extractor
8+
working_directory: ../..
9+
command: |
10+
patch -p1 < ./tools/rntv-workflows/microsoft-api-extractor.patch
11+
- run:
12+
name: Run Typescript generation
13+
working_directory: ../..
14+
command: |
15+
if [[ "$RNTV_RELEASE_BUILD" != "1" ]]; then
16+
yarn build-types
17+
fi
18+
- run:
19+
name: Set up build-specific environment
20+
working_directory: ../..
21+
command: |
22+
# Set up environment for subsequent steps
23+
# Location for NPM tarballs
24+
export NPM_TARBALL_LOCATION=$PWD/npm-tarballs
25+
mkdir -p $NPM_TARBALL_LOCATION
26+
set-env NPM_TARBALL_LOCATION $NPM_TARBALL_LOCATION
27+
# Root directory
28+
export ROOT_DIR=$PWD
29+
set-env ROOT_DIR $ROOT_DIR
30+
- run:
31+
name: Create virtualized-lists tarball
32+
working_directory: ../../packages/virtualized-lists
33+
command: |
34+
npm pack --pack-destination $ROOT_DIR
35+
- run:
36+
name: Create react-native tarball
37+
working_directory: ../../packages/react-native
38+
command: |
39+
npm pack --pack-destination $ROOT_DIR
40+
- eas/upload_artifact:
41+
name: Upload Android artifacts and NPM tarballs
42+
inputs:
43+
type: build-artifact
44+
path: |
45+
react-native-*.tgz
Lines changed: 56 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,76 @@
11
build:
2-
name: Build RNTester app for Android TV
2+
name: Build RNTester for Android platforms
33
steps:
44
- eas/checkout
55
- eas/install_node_modules
66
- run:
77
name: Set up build-specific environment
88
working_directory: ../..
99
command: |
10-
. ./tools/rntv-workflows/override-nightly-build-version.sh
11-
echo "Hermes build from nightly build: $REACT_NATIVE_OVERRIDE_NIGHTLY_BUILD_VERSION"
1210
# Set up environment for subsequent steps
13-
set-env REACT_NATIVE_OVERRIDE_NIGHTLY_BUILD_VERSION $REACT_NATIVE_OVERRIDE_NIGHTLY_BUILD_VERSION
1411
# Check and save sdkmanager path
1512
export ANDROID_CUSTOM_SDKMANAGER_PATH=`which sdkmanager`
1613
echo "ANDROID_CUSTOM_SDKMANAGER_PATH: $ANDROID_CUSTOM_SDKMANAGER_PATH"
1714
set-env ANDROID_CUSTOM_SDKMANAGER_PATH $ANDROID_CUSTOM_SDKMANAGER_PATH
15+
# Install cmake
16+
echo "Installing CMake 3.30.5..."
17+
sdkmanager --install "cmake;3.30.5"
18+
# Location for RNTester APKs
19+
export RNTESTER_APK_LOCATION=$PWD/RNTester-Android
20+
mkdir -p $RNTESTER_APK_LOCATION/Debug
21+
mkdir -p $RNTESTER_APK_LOCATION/Release
22+
set-env RNTESTER_APK_LOCATION $RNTESTER_APK_LOCATION
23+
# Root directory
24+
export ROOT_DIR=$PWD
25+
set-env ROOT_DIR $ROOT_DIR
26+
if [[ "$RNTV_RELEASE_BUILD" != "1" ]]; then
27+
. ./tools/rntv-workflows/override-nightly-build-version.sh
28+
echo "Hermes build from nightly build: $REACT_NATIVE_OVERRIDE_NIGHTLY_BUILD_VERSION"
29+
set-env REACT_NATIVE_OVERRIDE_NIGHTLY_BUILD_VERSION $REACT_NATIVE_OVERRIDE_NIGHTLY_BUILD_VERSION
30+
# node ./scripts/releases/use-hermes-nightly.js
31+
yarn
32+
set-env HERMES_VERSION nightly
33+
set-env RN_DEP_VERSION nightly
34+
fi
1835
- run:
19-
name: Build RNTester app for Android and Android TV
20-
working_directory: ../../packages/rn-tester
36+
name: Unpack build artifacts
37+
working_directory: .
38+
command: |
39+
DEBUG=eas:* npx eas-cli build:view $ARTIFACTS_BUILD_ID --json > build.json && true
40+
curl --output ../../react-native-artifacts.tgz `node -e 'console.log(require("./build.json").artifacts.buildArtifactsUrl)'`
41+
mkdir $ROOT_DIR/maven-local
42+
(cd $ROOT_DIR/maven-local; tar zxf ../react-native-artifacts.tgz)
43+
- run:
44+
name: Build RNTester app for Android and Android TV (Debug)
45+
working_directory: ../..
2146
command: |
22-
echo "Cleaning build directories..."
23-
yarn clean-android
2447
echo "Building RNTester..."
25-
yarn build-android-hermes
48+
export REACT_NATIVE_VERSION=`npx tsx tools/rntv-workflows/src/get-react-native-version.ts`
49+
./gradlew -PreactNativeMavenLocalPath=$ROOT_DIR/maven-local -PreactNativeArtifactVersion=$REACT_NATIVE_VERSION :packages:rn-tester:android:app:assembleDebug
50+
echo "Copying RNTester APKs to $RNTESTER_APK_LOCATION..."
51+
cp -r packages/rn-tester/android/app/build/outputs/apk/debug/* $RNTESTER_APK_LOCATION/Debug
2652
echo "Build completed."
53+
- run:
54+
name: Build RNTester app for Android and Android TV (Release)
55+
working_directory: ../..
56+
command: |
57+
echo "Building RNTester..."
58+
export REACT_NATIVE_VERSION=`npx tsx tools/rntv-workflows/src/get-react-native-version.ts`
59+
./gradlew -PreactNativeMavenLocalPath=$ROOT_DIR/maven-local -PreactNativeArtifactVersion=$REACT_NATIVE_VERSION :packages:rn-tester:android:app:assembleRelease
60+
echo "Copying RNTester APKs to $RNTESTER_APK_LOCATION..."
61+
cp -r packages/rn-tester/android/app/build/outputs/apk/release/* $RNTESTER_APK_LOCATION/Release
62+
echo "Build completed."
63+
- run:
64+
name: Package Android artifacts
65+
working_directory: ../..
66+
command: |
67+
export REACT_NATIVE_VERSION=`npx tsx tools/rntv-workflows/src/get-react-native-version.ts`
68+
echo "REACT_NATIVE_VERSION: $REACT_NATIVE_VERSION"
69+
(cd RNTester-Android/Debug; tar zcf $ROOT_DIR/rntester-$REACT_NATIVE_VERSION-androidtv-debug.tgz *)
70+
(cd RNTester-Android/Release; tar zcf $ROOT_DIR/rntester-$REACT_NATIVE_VERSION-androidtv-release.tgz *)
2771
- eas/upload_artifact:
28-
name: Upload RNTester artifacts
72+
name: Upload Android artifacts and NPM tarballs
2973
inputs:
30-
type: application-archive
74+
type: build-artifact
3175
path: |
32-
packages/rn-tester/android/app/build/outputs/apk/debug/app-arm64-v8a-debug.apk
76+
rntester-*.tgz

0 commit comments

Comments
 (0)