@@ -185,21 +185,31 @@ private async Task DownloadLatestRunner(CancellationToken token)
185
185
#if DEBUG
186
186
// Much of the update process (targetVersion, archive) is server-side, this is a way to control it from here for testing specific update scenarios
187
187
// Add files like 'runner_v2.281.2.tar.gz' or 'runner_v2.283.0.zip' depending on your platform in your runner root folder
188
+ // This functionality should not be in the release build to prevent tampering with updates
188
189
var isMockUpdate = StringUtil . ConvertToBoolean ( Environment . GetEnvironmentVariable ( "GITHUB_ACTIONS_RUNNER_IS_MOCK_UPDATE" ) ) ;
189
190
if ( isMockUpdate )
190
191
{
191
- // the env var should be of format 'v2.281.2,v2.283.0,v2.283.1,v2.284.0'
192
+ // the env var should be of format GITHUB_ACTIONS_RUNNER_MOCK_VERSION_LIST= 'v2.281.2,v2.283.0,v2.283.1,v2.284.0'
192
193
var mockVersions = Environment . GetEnvironmentVariable ( "GITHUB_ACTIONS_RUNNER_MOCK_VERSION_LIST" ) . Split ( ',' ) ;
193
194
if ( mockVersions . Any ( ) )
194
195
{
195
196
var targetVersion = mockVersions . First ( ) ;
196
- archiveFile = "runner_" + targetVersion ;
197
+
198
+ if ( _targetPackage . Platform . StartsWith ( "win" ) )
199
+ {
200
+ archiveFile = Path . Combine ( HostContext . GetDirectory ( WellKnownDirectory . Root ) , $ "runner{ targetVersion } .zip") ;
201
+ }
202
+ else
203
+ {
204
+ archiveFile = Path . Combine ( HostContext . GetDirectory ( WellKnownDirectory . Root ) , $ "runner{ targetVersion } .tar.gz") ;
205
+ }
206
+
197
207
var newMockVersions = string . Join ( "," , mockVersions . Skip ( 1 ) ) ;
198
208
Environment . SetEnvironmentVariable ( "GITHUB_ACTIONS_RUNNER_MOCK_VERSION_LIST" , newMockVersions ) ;
199
209
_updateTrace . Add ( $ "Mocking update with file: { archiveFile } , nothing is downloaded") ;
200
210
}
201
211
}
202
- #else
212
+ #endif
203
213
// archiveFile is not null only if we mocked it above
204
214
if ( archiveFile == null )
205
215
{
@@ -211,7 +221,6 @@ private async Task DownloadLatestRunner(CancellationToken token)
211
221
}
212
222
await ValidateRunnerHash ( archiveFile , packageHashValue ) ;
213
223
}
214
- #endif
215
224
216
225
await ExtractRunnerPackage ( archiveFile , latestRunnerDirectory , token ) ;
217
226
}
0 commit comments