From 0f4868ace7471f447c52e9dd0ec7212d864b754e Mon Sep 17 00:00:00 2001 From: Tommy Nguyen <4123478+tido64@users.noreply.github.com> Date: Thu, 30 May 2024 08:38:18 +0200 Subject: [PATCH] fix(build): fix `rnx-build-apple` not being resolved (#3168) --- .changeset/strange-donuts-beg.md | 5 +++++ .github/workflows/rnx-build.yml | 12 ++++++------ incubator/build/package.json | 3 +++ incubator/build/workflows/github.yml | 12 ++++++------ packages/test-app/package.json | 1 + yarn.lock | 3 ++- 6 files changed, 23 insertions(+), 13 deletions(-) create mode 100644 .changeset/strange-donuts-beg.md diff --git a/.changeset/strange-donuts-beg.md b/.changeset/strange-donuts-beg.md new file mode 100644 index 000000000..5dce67491 --- /dev/null +++ b/.changeset/strange-donuts-beg.md @@ -0,0 +1,5 @@ +--- +"@rnx-kit/build": patch +--- + +Fix `rnx-build-apple` not being resolved correctly in pnpm setups diff --git a/.github/workflows/rnx-build.yml b/.github/workflows/rnx-build.yml index 10af1fa0b..0e27cace2 100644 --- a/.github/workflows/rnx-build.yml +++ b/.github/workflows/rnx-build.yml @@ -83,21 +83,21 @@ jobs: BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }} KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} P12_PASSWORD: ${{ secrets.P12_PASSWORD }} - run: npx --prefix . rnx-build-apple install-certificate + run: /bin/bash $(node --print 'require.resolve("@rnx-kit/build/scripts/build-apple")') install-certificate - name: Build iOS app - run: npx --prefix . rnx-build-apple build-ios --scheme ${{ github.event.inputs.scheme }} --device-type ${{ github.event.inputs.deviceType }} --archs ${{ github.event.inputs.architecture }} + run: /bin/bash $(node --print 'require.resolve("@rnx-kit/build/scripts/build-apple")') build-ios --scheme ${{ github.event.inputs.scheme }} --device-type ${{ github.event.inputs.deviceType }} --archs ${{ github.event.inputs.architecture }} working-directory: ${{ github.event.inputs.projectRoot }}/ios - name: Remove Apple signing certificate and provisioning profile # Always run this job step, even if previous ones fail. See also # https://docs.github.com/en/actions/deployment/deploying-xcode-applications/installing-an-apple-certificate-on-macos-runners-for-xcode-development#required-clean-up-on-self-hosted-runners if: ${{ always() && github.event.inputs.deviceType == 'device' }} - run: npx --prefix . rnx-build-apple uninstall-certificate + run: /bin/bash $(node --print 'require.resolve("@rnx-kit/build/scripts/build-apple")') uninstall-certificate - name: Prepare build artifact id: prepare-build-artifact run: | if [[ ${{ github.event.inputs.distribution }} == 'local' ]]; then app=$(find ${XCARCHIVE_FILE}/Products/Applications -maxdepth 1 -name '*.app' -type d | head -1) - npx --prefix . rnx-build-apple archive ios-artifact.tar "${app}" + /bin/bash $(node --print 'require.resolve("@rnx-kit/build/scripts/build-apple")') archive ios-artifact.tar "${app}" echo 'filename=ios-artifact.tar' >> $GITHUB_OUTPUT else xcodebuild -exportArchive -archivePath ${XCARCHIVE_FILE} -exportPath export -exportOptionsPlist ExportOptions.plist 2>&1 @@ -131,13 +131,13 @@ jobs: run: pod install --project-directory=macos --verbose working-directory: ${{ github.event.inputs.projectRoot }} - name: Build macOS app - run: npx --prefix . rnx-build-apple build-macos --scheme ${{ github.event.inputs.scheme }} + run: /bin/bash $(node --print 'require.resolve("@rnx-kit/build/scripts/build-apple")') build-macos --scheme ${{ github.event.inputs.scheme }} working-directory: ${{ github.event.inputs.projectRoot }}/macos - name: Prepare build artifact run: | output_path=DerivedData/Build/Products app=$(find ${output_path} -maxdepth 2 -name '*.app' -type d | head -1) - npx --prefix . rnx-build-apple archive macos-artifact.tar "${app}" + /bin/bash $(node --print 'require.resolve("@rnx-kit/build/scripts/build-apple")') archive macos-artifact.tar "${app}" working-directory: ${{ github.event.inputs.projectRoot }}/macos - name: Upload build artifact uses: actions/upload-artifact@v4 diff --git a/incubator/build/package.json b/incubator/build/package.json index de6485acf..ce7baa2cb 100644 --- a/incubator/build/package.json +++ b/incubator/build/package.json @@ -21,6 +21,9 @@ "types": "./lib/index.d.ts", "import": "./lib/index.js" }, + "./scripts/build-apple": { + "require": "./scripts/build-apple.sh" + }, "./package.json": "./package.json" }, "bin": { diff --git a/incubator/build/workflows/github.yml b/incubator/build/workflows/github.yml index 10af1fa0b..0e27cace2 100644 --- a/incubator/build/workflows/github.yml +++ b/incubator/build/workflows/github.yml @@ -83,21 +83,21 @@ jobs: BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }} KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} P12_PASSWORD: ${{ secrets.P12_PASSWORD }} - run: npx --prefix . rnx-build-apple install-certificate + run: /bin/bash $(node --print 'require.resolve("@rnx-kit/build/scripts/build-apple")') install-certificate - name: Build iOS app - run: npx --prefix . rnx-build-apple build-ios --scheme ${{ github.event.inputs.scheme }} --device-type ${{ github.event.inputs.deviceType }} --archs ${{ github.event.inputs.architecture }} + run: /bin/bash $(node --print 'require.resolve("@rnx-kit/build/scripts/build-apple")') build-ios --scheme ${{ github.event.inputs.scheme }} --device-type ${{ github.event.inputs.deviceType }} --archs ${{ github.event.inputs.architecture }} working-directory: ${{ github.event.inputs.projectRoot }}/ios - name: Remove Apple signing certificate and provisioning profile # Always run this job step, even if previous ones fail. See also # https://docs.github.com/en/actions/deployment/deploying-xcode-applications/installing-an-apple-certificate-on-macos-runners-for-xcode-development#required-clean-up-on-self-hosted-runners if: ${{ always() && github.event.inputs.deviceType == 'device' }} - run: npx --prefix . rnx-build-apple uninstall-certificate + run: /bin/bash $(node --print 'require.resolve("@rnx-kit/build/scripts/build-apple")') uninstall-certificate - name: Prepare build artifact id: prepare-build-artifact run: | if [[ ${{ github.event.inputs.distribution }} == 'local' ]]; then app=$(find ${XCARCHIVE_FILE}/Products/Applications -maxdepth 1 -name '*.app' -type d | head -1) - npx --prefix . rnx-build-apple archive ios-artifact.tar "${app}" + /bin/bash $(node --print 'require.resolve("@rnx-kit/build/scripts/build-apple")') archive ios-artifact.tar "${app}" echo 'filename=ios-artifact.tar' >> $GITHUB_OUTPUT else xcodebuild -exportArchive -archivePath ${XCARCHIVE_FILE} -exportPath export -exportOptionsPlist ExportOptions.plist 2>&1 @@ -131,13 +131,13 @@ jobs: run: pod install --project-directory=macos --verbose working-directory: ${{ github.event.inputs.projectRoot }} - name: Build macOS app - run: npx --prefix . rnx-build-apple build-macos --scheme ${{ github.event.inputs.scheme }} + run: /bin/bash $(node --print 'require.resolve("@rnx-kit/build/scripts/build-apple")') build-macos --scheme ${{ github.event.inputs.scheme }} working-directory: ${{ github.event.inputs.projectRoot }}/macos - name: Prepare build artifact run: | output_path=DerivedData/Build/Products app=$(find ${output_path} -maxdepth 2 -name '*.app' -type d | head -1) - npx --prefix . rnx-build-apple archive macos-artifact.tar "${app}" + /bin/bash $(node --print 'require.resolve("@rnx-kit/build/scripts/build-apple")') archive macos-artifact.tar "${app}" working-directory: ${{ github.event.inputs.projectRoot }}/macos - name: Upload build artifact uses: actions/upload-artifact@v4 diff --git a/packages/test-app/package.json b/packages/test-app/package.json index 9b8e9068c..7fc6e486a 100644 --- a/packages/test-app/package.json +++ b/packages/test-app/package.json @@ -41,6 +41,7 @@ "@react-native/babel-preset": "^0.73.0", "@react-native/metro-config": "^0.73.0", "@rnx-kit/babel-preset-metro-react-native": "workspace:*", + "@rnx-kit/build": "workspace:*", "@rnx-kit/cli": "workspace:*", "@rnx-kit/eslint-config": "workspace:*", "@rnx-kit/jest-preset": "workspace:*", diff --git a/yarn.lock b/yarn.lock index cf98b0c22..ba010f8de 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3660,7 +3660,7 @@ __metadata: languageName: unknown linkType: soft -"@rnx-kit/build@npm:*, @rnx-kit/build@workspace:incubator/build": +"@rnx-kit/build@npm:*, @rnx-kit/build@workspace:*, @rnx-kit/build@workspace:incubator/build": version: 0.0.0-use.local resolution: "@rnx-kit/build@workspace:incubator/build" dependencies: @@ -4408,6 +4408,7 @@ __metadata: "@react-native/babel-preset": "npm:^0.73.0" "@react-native/metro-config": "npm:^0.73.0" "@rnx-kit/babel-preset-metro-react-native": "workspace:*" + "@rnx-kit/build": "workspace:*" "@rnx-kit/cli": "workspace:*" "@rnx-kit/eslint-config": "workspace:*" "@rnx-kit/jest-preset": "workspace:*"