Skip to content

Commit

Permalink
Fix CI Upgrade again
Browse files Browse the repository at this point in the history
  • Loading branch information
jonthysell committed Feb 4, 2025
1 parent 5c737a5 commit 8a522b6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
45 changes: 23 additions & 22 deletions .github/scripts/UpgradeSmokeTest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,17 @@ Write-Host "UpgradeSmokeTest -RnwVersion $RnwVersion"

[string]$LocalRnwVersion = $null

Write-Host "Determining local react-native-windows version from yarn.lock..."
if (Test-Path "yarn.lock") {
[bool]$lineFound = $False
foreach($line in Get-Content "yarn.lock") {
if ($lineFound) {
$LocalRnwVersion = $line.Substring($line.IndexOf("""")).Trim("""")
Write-Host "Determining local react-native-windows version from yarn why"

$yarnWhy = & yarn why react-native-windows
foreach($line in $yarnWhy) {
if ($line.StartsWith("=> Found")) {
$LocalRnwVersion = $line.Substring($line.IndexOf("@")+1).Trim("""")
break;
} elseif ($line.Contains("react-native-windows@npm:")) {
$LocalRnwVersion = $line.Substring($line.IndexOf(":")+1).Split(' ')[0]
break;
}
if ($line.StartsWith("react-native-windows")) {
$lineFound = $True;
}
}
} else {
Write-Host "Exiting, yarn.lock not found."
exit 1
}

if ($LocalRnwVersion -eq $null) {
Expand Down Expand Up @@ -93,33 +89,38 @@ if ($Force) {
Write-Host "Starting upgrade..."
}

[string]$ReactVersion = npm info react-native-windows@$RnwVersion devDependencies.react
Write-Host "RNW $RnwVersion depends on react@$ReactVersion"
[string]$ReactVersion = npm info react-native-windows@$TargetRnwVersion devDependencies.react
Write-Host "RNW $TargetRnwVersion depends on react@$ReactVersion"

[string]$ReactNativeVersion = npm info react-native-windows@$RnwVersion devDependencies.react-native
Write-Host "RNW $RnwVersion depends on react-native@$ReactNativeVersion"
[string]$ReactNativeVersion = npm info react-native-windows@$TargetRnwVersion devDependencies.react-native
Write-Host "RNW $TargetRnwVersion depends on react-native@$ReactNativeVersion"

$yarnUpgradeCmd = "upgrade"
if (Test-Path ".yarn") {
$yarnUpgradeCmd = "up"
}

Write-Host "Upgrading to react@$ReactVersion..."
yarn.cmd upgrade react@$ReactVersion
yarn $yarnUpgradeCmd react@$ReactVersion

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

Write-Host "Upgrading to react-native@$ReactNativeVersion..."
yarn.cmd upgrade react-native@$ReactNativeVersion
yarn $yarnUpgradeCmd react-native@$ReactNativeVersion

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

Write-Host "Upgrading to react-native-windows@$RnwVersion..."
yarn.cmd upgrade react-native-windows@$RnwVersion
Write-Host "Upgrading to react-native-windows@$TargetRnwVersion..."
yarn $yarnUpgradeCmd react-native-windows@$TargetRnwVersion

if ($LastExitCode -ne 0) {
Write-Error "Failed to upgrade to react-native-windows@$RnwVersion"
Write-Error "Failed to upgrade to react-native-windows@$TargetRnwVersion"
exit $LastExitCode
}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ jobs:
configuration: ${{ matrix.configuration }}
platform: ${{ matrix.platform }}
extraRunWindowsArgs: --no-autolink --no-deploy
runCodeGenCheck: true
runCodeGenCheck: ${{ endsWith(matrix.sampleName, 'cpp-lib') }}

0 comments on commit 8a522b6

Please sign in to comment.