Skip to content

Commit 8a522b6

Browse files
committed
Fix CI Upgrade again
1 parent 5c737a5 commit 8a522b6

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

.github/scripts/UpgradeSmokeTest.ps1

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,17 @@ Write-Host "UpgradeSmokeTest -RnwVersion $RnwVersion"
4444

4545
[string]$LocalRnwVersion = $null
4646

47-
Write-Host "Determining local react-native-windows version from yarn.lock..."
48-
if (Test-Path "yarn.lock") {
49-
[bool]$lineFound = $False
50-
foreach($line in Get-Content "yarn.lock") {
51-
if ($lineFound) {
52-
$LocalRnwVersion = $line.Substring($line.IndexOf("""")).Trim("""")
47+
Write-Host "Determining local react-native-windows version from yarn why"
48+
49+
$yarnWhy = & yarn why react-native-windows
50+
foreach($line in $yarnWhy) {
51+
if ($line.StartsWith("=> Found")) {
52+
$LocalRnwVersion = $line.Substring($line.IndexOf("@")+1).Trim("""")
53+
break;
54+
} elseif ($line.Contains("react-native-windows@npm:")) {
55+
$LocalRnwVersion = $line.Substring($line.IndexOf(":")+1).Split(' ')[0]
5356
break;
5457
}
55-
if ($line.StartsWith("react-native-windows")) {
56-
$lineFound = $True;
57-
}
58-
}
59-
} else {
60-
Write-Host "Exiting, yarn.lock not found."
61-
exit 1
6258
}
6359

6460
if ($LocalRnwVersion -eq $null) {
@@ -93,33 +89,38 @@ if ($Force) {
9389
Write-Host "Starting upgrade..."
9490
}
9591

96-
[string]$ReactVersion = npm info react-native-windows@$RnwVersion devDependencies.react
97-
Write-Host "RNW $RnwVersion depends on react@$ReactVersion"
92+
[string]$ReactVersion = npm info react-native-windows@$TargetRnwVersion devDependencies.react
93+
Write-Host "RNW $TargetRnwVersion depends on react@$ReactVersion"
9894

99-
[string]$ReactNativeVersion = npm info react-native-windows@$RnwVersion devDependencies.react-native
100-
Write-Host "RNW $RnwVersion depends on react-native@$ReactNativeVersion"
95+
[string]$ReactNativeVersion = npm info react-native-windows@$TargetRnwVersion devDependencies.react-native
96+
Write-Host "RNW $TargetRnwVersion depends on react-native@$ReactNativeVersion"
97+
98+
$yarnUpgradeCmd = "upgrade"
99+
if (Test-Path ".yarn") {
100+
$yarnUpgradeCmd = "up"
101+
}
101102

102103
Write-Host "Upgrading to react@$ReactVersion..."
103-
yarn.cmd upgrade react@$ReactVersion
104+
yarn $yarnUpgradeCmd react@$ReactVersion
104105

105106
if ($LastExitCode -ne 0) {
106107
Write-Error "Failed to upgrade to react @$ReactVersion"
107108
exit $LastExitCode
108109
}
109110

110111
Write-Host "Upgrading to react-native@$ReactNativeVersion..."
111-
yarn.cmd upgrade react-native@$ReactNativeVersion
112+
yarn $yarnUpgradeCmd react-native@$ReactNativeVersion
112113

113114
if ($LastExitCode -ne 0) {
114115
Write-Error "Failed to upgrade to react-native@$ReactNativeVersion"
115116
exit $LastExitCode
116117
}
117118

118-
Write-Host "Upgrading to react-native-windows@$RnwVersion..."
119-
yarn.cmd upgrade react-native-windows@$RnwVersion
119+
Write-Host "Upgrading to react-native-windows@$TargetRnwVersion..."
120+
yarn $yarnUpgradeCmd react-native-windows@$TargetRnwVersion
120121

121122
if ($LastExitCode -ne 0) {
122-
Write-Error "Failed to upgrade to react-native-windows@$RnwVersion"
123+
Write-Error "Failed to upgrade to react-native-windows@$TargetRnwVersion"
123124
exit $LastExitCode
124125
}
125126

.github/workflows/ci-upgrade.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ jobs:
5151
configuration: ${{ matrix.configuration }}
5252
platform: ${{ matrix.platform }}
5353
extraRunWindowsArgs: --no-autolink --no-deploy
54-
runCodeGenCheck: true
54+
runCodeGenCheck: ${{ endsWith(matrix.sampleName, 'cpp-lib') }}

0 commit comments

Comments
 (0)