@@ -87,7 +87,7 @@ private async Task<bool> ExecuteInternalAsync()
8787 }
8888 if ( VersionsChanged )
8989 {
90- UpdateEnvVarsForPRFile ( versions ) ;
90+ UpdateEnvVarsForPRFile ( chromeVersionsXmlDoc , versions ) ;
9191 }
9292 return ! Log . HasLoggedErrors ;
9393 }
@@ -98,23 +98,30 @@ private async Task<bool> ExecuteInternalAsync()
9898 }
9999 }
100100
101- private static bool AreVersionsChanged ( XmlDocument xmlDoc , ChromeVersionSpec version , string baseUrl )
101+ private bool AreVersionsChanged ( XmlDocument xmlDoc , ChromeVersionSpec version , string baseUrl )
102102 {
103- if ( string . Equals ( version . os , "Linux" , StringComparison . OrdinalIgnoreCase ) )
103+ string nodePrefix = version . os switch
104104 {
105- string linuxChromeBaseSnapshotUrl = GetNodeValue ( xmlDoc , "linux_ChromeBaseSnapshotUrl" ) ;
106- string linuxV8Version = GetNodeValue ( xmlDoc , "linux_V8Version" ) ;
107- return version . v8_version != linuxV8Version ||
108- baseUrl != linuxChromeBaseSnapshotUrl ;
109- }
110- else if ( string . Equals ( version . os , "Windows" , StringComparison . OrdinalIgnoreCase ) )
105+ _ when string . Equals ( version . os , "Linux" , StringComparison . OrdinalIgnoreCase ) => "linux" ,
106+ _ when string . Equals ( version . os , "Windows" , StringComparison . OrdinalIgnoreCase ) => "win" ,
107+ _ when string . Equals ( version . os , "Mac" , StringComparison . OrdinalIgnoreCase ) => "macos" ,
108+ _ => throw new Exception ( $ "UpdateChromeVersions task was used with unknown OS: { version . os } ")
109+ } ;
110+
111+ string existingChromeVersion = GetNodeValue ( xmlDoc , $ "{ nodePrefix } _ChromeVersion") ;
112+ if ( Version . TryParse ( existingChromeVersion , out Version ? existing ) &&
113+ Version . TryParse ( version . version , out Version ? candidate ) &&
114+ candidate < existing )
111115 {
112- string winChromeBaseSnapshotUrl = GetNodeValue ( xmlDoc , "win_ChromeBaseSnapshotUrl" ) ;
113- string winV8Version = GetNodeValue ( xmlDoc , "win_V8Version" ) ;
114- return version . v8_version != winV8Version ||
115- baseUrl != winChromeBaseSnapshotUrl ;
116+ Log . LogMessage ( MessageImportance . High ,
117+ $ "Skipping { version . os } : candidate version { version . version } is older than existing { existingChromeVersion } .") ;
118+ return false ;
116119 }
117- throw new Exception ( $ "UpdateChromeVersions task was used with unknown OS: { version . os } ") ;
120+
121+ string existingChromeBaseSnapshotUrl = GetNodeValue ( xmlDoc , $ "{ nodePrefix } _ChromeBaseSnapshotUrl") ;
122+ string existingV8Version = GetNodeValue ( xmlDoc , $ "{ nodePrefix } _V8Version") ;
123+ return version . v8_version != existingV8Version ||
124+ baseUrl != existingChromeBaseSnapshotUrl ;
118125 }
119126
120127 private static string GetNodeValue ( XmlDocument xmlDoc , string nodeName )
@@ -139,6 +146,13 @@ private bool UpdateChromeVersionsFile(XmlDocument xmlDoc, ChromeVersionSpec vers
139146 UpdateNodeValue ( xmlDoc , "win_ChromeBaseSnapshotUrl" , baseUrl ) ;
140147 UpdateNodeValue ( xmlDoc , "win_V8Version" , version . v8_version ) ;
141148 }
149+ else if ( string . Equals ( version . os , "Mac" , StringComparison . OrdinalIgnoreCase ) )
150+ {
151+ UpdateNodeValue ( xmlDoc , "macos_ChromeVersion" , version . version ) ;
152+ UpdateNodeValue ( xmlDoc , "macos_ChromeRevision" , version . branch_base_position ) ;
153+ UpdateNodeValue ( xmlDoc , "macos_ChromeBaseSnapshotUrl" , baseUrl ) ;
154+ UpdateNodeValue ( xmlDoc , "macos_V8Version" , version . v8_version ) ;
155+ }
142156 else
143157 {
144158 throw new Exception ( $ "UpdateChromeVersions task was used with unknown OS: { version . os } ") ;
@@ -147,18 +161,22 @@ private bool UpdateChromeVersionsFile(XmlDocument xmlDoc, ChromeVersionSpec vers
147161 return true ;
148162 }
149163
150- private void UpdateEnvVarsForPRFile ( List < ChromeVersionSpec > versions )
164+ private void UpdateEnvVarsForPRFile ( XmlDocument xmlDoc , List < ChromeVersionSpec > versions )
151165 {
152166 using StreamWriter writer = new StreamWriter ( EnvVarsForPRPath ) ;
153167 foreach ( var version in versions )
154168 {
155169 if ( string . Equals ( version . os , "Linux" , StringComparison . OrdinalIgnoreCase ) )
156170 {
157- writer . WriteLine ( $ "CHROME_LINUX_VER={ version . version } ") ;
171+ writer . WriteLine ( $ "CHROME_LINUX_VER={ GetNodeValue ( xmlDoc , "linux_ChromeVersion" ) } ") ;
158172 }
159173 else if ( string . Equals ( version . os , "Windows" , StringComparison . OrdinalIgnoreCase ) )
160174 {
161- writer . WriteLine ( $ "CHROME_WIN_VER={ version . version } ") ;
175+ writer . WriteLine ( $ "CHROME_WIN_VER={ GetNodeValue ( xmlDoc , "win_ChromeVersion" ) } ") ;
176+ }
177+ else if ( string . Equals ( version . os , "Mac" , StringComparison . OrdinalIgnoreCase ) )
178+ {
179+ writer . WriteLine ( $ "CHROME_MAC_VER={ GetNodeValue ( xmlDoc , "macos_ChromeVersion" ) } ") ;
162180 }
163181 else
164182 {
@@ -210,7 +228,9 @@ private static void UpdateNodeValue(XmlDocument xmlDoc, string nodeName, string
210228 ? "linux_V8Version"
211229 : string . Equals ( osIdentifier , "windows" , StringComparison . OrdinalIgnoreCase )
212230 ? "win_V8Version"
213- : throw new LogAsErrorException ( $ "Unknown OS identifier '{ osIdentifier } ' for V8 version fallback") ;
231+ : string . Equals ( osIdentifier , "Mac" , StringComparison . OrdinalIgnoreCase )
232+ ? "macos_V8Version"
233+ : throw new LogAsErrorException ( $ "Unknown OS identifier '{ osIdentifier } ' for V8 version fallback") ;
214234 foundV8Version = GetNodeValue ( existingDoc , existingV8VersionNodeName ) ;
215235 if ( string . IsNullOrEmpty ( foundV8Version ) )
216236 throw new LogAsErrorException ( $ "V8 binary for { osIdentifier } not available on CDN and no existing version found in { ChromeVersionsPath } ") ;
@@ -265,6 +285,7 @@ private static string GetV8BinaryUrl(string osPrefix, string v8Version)
265285 {
266286 "Linux_x64" => "linux64" ,
267287 "Win_x64" => "win32" ,
288+ "Mac_Arm" => "mac-arm64" ,
268289 _ => throw new ArgumentException ( $ "Unknown OS prefix '{ osPrefix } ' for V8 binary URL")
269290 } ;
270291 return $ "{ s_v8CanaryBaseUrl } /v8-{ jsvuPlatform } -rel-{ v8Version } .zip";
0 commit comments