Skip to content

Commit da88bf0

Browse files
cipolleschifacebook-github-bot
authored andcommitted
Add job to build the slices for ios prebuilds (facebook#49528)
Summary: Pull Request resolved: facebook#49528 This change introduces a job to prebuild iOS slices. ## Changelog: [Internal] - Create prepare artifacts workflows Reviewed By: cortinico Differential Revision: D69855542 fbshipit-source-id: 54d5b24b55f9e7bebdbb201073524dc4f3748e07
1 parent 3c03e2b commit da88bf0

File tree

6 files changed

+122
-23
lines changed

6 files changed

+122
-23
lines changed

.github/workflows/prebuild-ios.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,71 @@ jobs:
4343
key: v1-ios-dependencies-${{ hashfiles('scripts/releases/ios-prebuilds/configuration.js') }}
4444
enableCrossOsArchive: true
4545
path: packages/react-native/third-party/
46+
47+
build-apple-slices:
48+
name: Build Apple Slice
49+
runs-on: macos-14
50+
needs: [prepare_workspace]
51+
strategy:
52+
fail-fast: false
53+
matrix:
54+
flavor: ['Debug', 'Release']
55+
slice: ['ios',
56+
'ios-simulator',
57+
'macos',
58+
'mac-catalyst',
59+
'tvos',
60+
'tvos-simulator',
61+
'xros',
62+
'xros-simulator']
63+
steps:
64+
- name: Checkout
65+
uses: actions/checkout@v4
66+
- name: Setup node.js
67+
uses: ./.github/actions/setup-node
68+
- name: Setup xcode
69+
uses: ./.github/actions/setup-xcode
70+
with:
71+
xcode-version: '16.1'
72+
- name: Restore slice folder
73+
id: restore-slice-folder
74+
uses: actions/cache/restore@v4
75+
with:
76+
path: packages/react-native/third-party/.build/Build/Products
77+
key: v1-ios-dependencies-slice-folder-${{ matrix.slice }}-${{ matrix.flavor }}-${{ hashfiles('scripts/releases/ios-prebuilds/configuration.js') }}
78+
- name: Yarn Install
79+
if: steps.restore-slice-folder.outputs.cache-hit != 'true'
80+
uses: ./.github/actions/yarn-install
81+
- name: Restore workspace
82+
if: steps.restore-slice-folder.outputs.cache-hit != 'true'
83+
uses: actions/download-artifact@v4
84+
with:
85+
name: ios-prebuilds-workspace
86+
path: packages/react-native/third-party/
87+
- name: Print third-party folder structure
88+
run: ls -lR packages/react-native/third-party
89+
- name: Install VisionOS
90+
if: ${{ steps.restore-slice-folder.outputs.cache-hit != 'true' && (matrix.slice == 'xros' || matrix.slice == 'xros-simulator') }}
91+
run: |
92+
# https://github.com/actions/runner-images/issues/10559
93+
sudo xcodebuild -runFirstLaunch
94+
sudo xcrun simctl list
95+
sudo xcodebuild -downloadPlatform visionOS
96+
sudo xcodebuild -runFirstLaunch
97+
- name: Build slice ${{ matrix.slice }} for ${{ matrix.flavor }}
98+
if: steps.restore-slice-folder.outputs.cache-hit != 'true'
99+
run: node scripts/releases/prepare-ios-prebuilds.js -b -p ${{ matrix.slice }} -r ${{ matrix.flavor }}
100+
- name: Upload Artifacts
101+
uses: actions/[email protected]
102+
with:
103+
name: ios-slice-${{ matrix.flavor }}-${{ matrix.slice }}
104+
path: |
105+
packages/react-native/third-party/.build/Build/Products
106+
- name: Save Cache
107+
uses: actions/cache/save@v4
108+
if: ${{ github.ref == 'refs/heads/main' }} # To avoid that the cache explode
109+
with:
110+
key: v1-ios-dependencies-slice-folder-${{ matrix.slice }}-${{ matrix.flavor }}-${{ hashfiles('scripts/releases/ios-prebuilds/configuration.js') }}
111+
enableCrossOsArchive: true
112+
path: |
113+
packages/react-native/third-party/.build/Build/Products

scripts/releases/ios-prebuild/build.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const fs = require('fs');
1616
const path = require('path');
1717

1818
/*::
19-
import type { Dependency, Platform } from './types';
19+
import type { Dependency, Destination, Platform } from './types';
2020
*/
2121

2222
/**
@@ -28,15 +28,21 @@ async function buildDepenencies(
2828
scheme /*: string */,
2929
configuration /*: string */,
3030
dependencies /*: $ReadOnlyArray<Dependency> */,
31-
platforms /*: $ReadOnlyArray<Platform> */,
31+
destinations /*: $ReadOnlyArray<Destination> */,
3232
rootFolder /*: string */,
3333
buildFolder /*: string */,
3434
) {
3535
console.log('✅ Building dependencies...');
3636

3737
await Promise.all(
38-
platforms.map(platform =>
39-
buildPlatform(scheme, configuration, platform, rootFolder, buildFolder),
38+
destinations.map(destination =>
39+
buildPlatform(
40+
scheme,
41+
configuration,
42+
destination,
43+
rootFolder,
44+
buildFolder,
45+
),
4046
),
4147
);
4248

@@ -50,13 +56,13 @@ async function buildDepenencies(
5056
async function buildPlatform(
5157
scheme /*: string */,
5258
configuration /*: string */,
53-
platform /*: Platform */,
59+
destination /*: Destination */,
5460
rootFolder /*: string */,
5561
buildFolder /*: string */,
5662
) {
57-
console.log(`Building ${platform}...`);
63+
console.log(`Building ${destination}...`);
5864
const command =
59-
`xcodebuild -scheme "${scheme}" -destination "generic/platform=${platform}" ` +
65+
`xcodebuild -scheme "${scheme}" -destination "generic/platform=${destination}" ` +
6066
`-derivedDataPath "${buildFolder}" ` +
6167
`-configuration "${configuration}" ` +
6268
'SKIP_INSTALL=NO \

scripts/releases/ios-prebuild/cli.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,22 @@ const {dependencies, platforms} = require('./configuration');
1313
const yargs = require('yargs');
1414

1515
/*::
16-
import type {Dependency, Platform} from './types';
16+
import type {Dependency, Destination, Platform} from './types';
1717
*/
1818

19+
// CI can't use commas in cache keys, so 'macOS,variant=Mac Catalyst' was creating troubles
20+
// This map that converts from platforms to valid Xcodebuild destinations.
21+
const platformToDestination /*: $ReadOnly<{|[Platform]: Destination|}> */ = {
22+
ios: 'iOS',
23+
'ios-simulator': 'iOS Simulator',
24+
macos: 'macOS',
25+
'mac-catalyst': 'macOS,variant=Mac Catalyst',
26+
tvos: 'tvOS',
27+
'tvos-simulator': 'tvOS Simulator',
28+
xros: 'visionOS',
29+
'xros-simulator': 'visionOS Simulator',
30+
};
31+
1932
const arrayLike = (value /*: Array<any> */) /*: Array<any> */ =>
2033
Array.isArray(value) ? value : [value];
2134

@@ -74,7 +87,7 @@ async function getCLIConfiguration() /*: Promise<?{|
7487
build: boolean,
7588
compose: boolean,
7689
|},
77-
platforms: $ReadOnlyArray<Platform>,
90+
destinations: $ReadOnlyArray<Destination>,
7891
dependencies: $ReadOnlyArray<Dependency>,
7992
configuration: string,
8093
|}> */ {
@@ -102,7 +115,9 @@ async function getCLIConfiguration() /*: Promise<?{|
102115
}
103116

104117
// Prepare platforms and dependencies
105-
const resolvedPlatforms = platforms.filter(p => argv.platforms.includes(p));
118+
const resolvedPlatforms = platforms
119+
.filter(p => argv.platforms.includes(p))
120+
.map(p => platformToDestination[p]);
106121
const resolvedDependencies = dependencies.filter(d =>
107122
argv.dependencies.includes(d.name),
108123
);
@@ -121,7 +136,7 @@ async function getCLIConfiguration() /*: Promise<?{|
121136
build: runAllCommands || argv.build != null,
122137
compose: runAllCommands || argv.compose != null,
123138
},
124-
platforms: resolvedPlatforms,
139+
destinations: resolvedPlatforms,
125140
dependencies: resolvedDependencies,
126141
configuration: argv.configuration,
127142
};

scripts/releases/ios-prebuild/configuration.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ import type { Dependency, Platform } from './types';
1414
*/
1515

1616
const platforms /*: $ReadOnlyArray<Platform> */ = [
17-
'iOS',
18-
'iOS Simulator',
19-
'macOS',
20-
'macOS,variant=Mac Catalyst',
21-
'tvOS',
22-
'tvOS Simulator',
23-
'visionOS',
24-
'visionOS Simulator',
17+
'ios',
18+
'ios-simulator',
19+
'macos',
20+
'mac-catalyst',
21+
'tvos',
22+
'tvos-simulator',
23+
'xros',
24+
'xros-simulator',
2525
];
2626

2727
const CPP_STANDARD = 'c++20';

scripts/releases/ios-prebuild/types.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,23 @@ export type Dependency = $ReadOnly<{
4949
}>;
5050
5151
export type Platform =
52+
'ios' |
53+
'ios-simulator' |
54+
'macos' |
55+
'mac-catalyst' |
56+
'tvos' |
57+
'tvos-simulator' |
58+
'xros' |
59+
'xros-simulator';
60+
61+
export type Destination =
5262
'iOS' |
53-
'iOS Simulator' |
54-
'macOS' |
63+
'iOS Simulator' |
64+
'macOS' |
5565
'macOS,variant=Mac Catalyst' |
5666
'tvOS' |
5767
'tvOS Simulator' |
58-
'visionOS' |
68+
'visionOS' |
5969
'visionOS Simulator';
6070
*/
6171

scripts/releases/prepare-ios-prebuilds.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async function main() {
5252
SCHEME,
5353
cli.configuration,
5454
cli.dependencies,
55-
cli.platforms,
55+
cli.destinations,
5656
rootFolder,
5757
buildFolder,
5858
);

0 commit comments

Comments
 (0)