Skip to content

Commit b5c5b5c

Browse files
committed
Suffix with correct archive format
1 parent 6fabd82 commit b5c5b5c

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/Runner.Listener/SelfUpdater.cs

+13-4
Original file line numberDiff line numberDiff line change
@@ -185,21 +185,31 @@ private async Task DownloadLatestRunner(CancellationToken token)
185185
#if DEBUG
186186
// Much of the update process (targetVersion, archive) is server-side, this is a way to control it from here for testing specific update scenarios
187187
// 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
188189
var isMockUpdate = StringUtil.ConvertToBoolean(Environment.GetEnvironmentVariable("GITHUB_ACTIONS_RUNNER_IS_MOCK_UPDATE"));
189190
if (isMockUpdate)
190191
{
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'
192193
var mockVersions = Environment.GetEnvironmentVariable("GITHUB_ACTIONS_RUNNER_MOCK_VERSION_LIST").Split(',');
193194
if (mockVersions.Any())
194195
{
195196
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+
197207
var newMockVersions = string.Join(",", mockVersions.Skip(1));
198208
Environment.SetEnvironmentVariable("GITHUB_ACTIONS_RUNNER_MOCK_VERSION_LIST", newMockVersions);
199209
_updateTrace.Add($"Mocking update with file: {archiveFile}, nothing is downloaded");
200210
}
201211
}
202-
#else
212+
#endif
203213
// archiveFile is not null only if we mocked it above
204214
if (archiveFile == null)
205215
{
@@ -211,7 +221,6 @@ private async Task DownloadLatestRunner(CancellationToken token)
211221
}
212222
await ValidateRunnerHash(archiveFile, packageHashValue);
213223
}
214-
#endif
215224

216225
await ExtractRunnerPackage(archiveFile, latestRunnerDirectory, token);
217226
}

0 commit comments

Comments
 (0)