Resolving issues with Self-Hosted GitHub Runners and local caches (#71)

* Removing downloaded ZIP before downloading another version

* Removing existing aliases before creating a new alias

* Removing existing installations before extracting downloaded ZIP

* Removing existing installations recursively

* Remove bin directory before creating aliases

* Recreate bin folder after clearing

* Fixed comments
This commit is contained in:
Lulu 2024-01-30 15:38:02 +01:00 committed by GitHub
parent 1af6893043
commit d3fbddfbaf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 44 additions and 1 deletions

17
dist/index.js generated vendored
View File

@ -125,15 +125,24 @@ function run(platform) {
core.info(`🙃 Previous Godot download not found in cache`);
core.endGroup();
core.startGroup(`📥 Downloading Godot to ${godotDownloadPath}...`);
// If the ZIP file already exists locally, delete it before downloading
if (fs.existsSync(godotDownloadPath))
fs.rmSync(godotDownloadPath);
const godotDownloadedPath = yield toolsCache.downloadTool(godotUrl, godotDownloadPath);
core.info(`✅ Godot downloaded to ${godotDownloadedPath}`);
core.endGroup();
core.startGroup(`📥 Downloading Export Templates to ${exportTemplateDownloadPath}...`);
// If the ZIP file already exists locally, delete it before downloading
if (fs.existsSync(exportTemplateDownloadPath))
fs.rmSync(exportTemplateDownloadPath);
const templateDownloadedPath = yield toolsCache.downloadTool(exportTemplateUrl, exportTemplateDownloadPath);
core.info(`✅ Export Templates downloaded to ${templateDownloadedPath}`);
core.endGroup();
// Extract Godot
core.startGroup(`📦 Extracting Godot to ${installationDir}...`);
// If the godot installation folder already exists, remove it before extracting the ZIP file. This will "uninstall" other installations (e.g. on version changes).
if (fs.existsSync(installationDir))
fs.rmdirSync(installationDir, { recursive: true });
const godotExtractedPath = yield toolsCache.extractZip(godotDownloadedPath, installationDir);
core.info(`✅ Godot extracted to ${godotExtractedPath}`);
core.endGroup();
@ -143,6 +152,9 @@ function run(platform) {
core.info(`✅ Files shown`);
core.endGroup();
core.startGroup(`📦 Extracting Export Templates to ${exportTemplatePath}...`);
// If the export template folder already exists, remove it before extracting the ZIP file. This will "uninstall" other installations (e.g. on version changes).
if (fs.existsSync(exportTemplatePath))
fs.rmdirSync(exportTemplatePath, { recursive: true });
const exportTemplateExtractedPath = yield toolsCache.extractZip(templateDownloadedPath, path_1.default.dirname(exportTemplatePath));
core.info(`✅ Export Templates extracted to ${exportTemplateExtractedPath}`);
fs.renameSync(path_1.default.join(exportTemplateExtractedPath, 'templates'), exportTemplatePath);
@ -201,6 +213,11 @@ function run(platform) {
// Create symlink to Godot executable
const godotAlias = path_1.default.join(binDir, 'godot');
core.startGroup(`🔗 Creating symlinks to executables...`);
// If an alias already exists, clear the bin folder before creating the new alias
if (fs.existsSync(binDir)) {
fs.rmSync(binDir, { recursive: true, force: true });
fs.mkdirSync(binDir, { recursive: true });
}
fs.linkSync(godotExecutable, godotAlias);
core.info(`✅ Symlink to Godot created`);
const godotSharpDirAlias = path_1.default.join(binDir, 'GodotSharp');

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -120,6 +120,10 @@ async function run(platform: Platform): Promise<void> {
core.endGroup()
core.startGroup(`📥 Downloading Godot to ${godotDownloadPath}...`)
// If the ZIP file already exists locally, delete it before downloading
if (fs.existsSync(godotDownloadPath)) fs.rmSync(godotDownloadPath)
const godotDownloadedPath = await toolsCache.downloadTool(
godotUrl,
godotDownloadPath
@ -130,6 +134,11 @@ async function run(platform: Platform): Promise<void> {
core.startGroup(
`📥 Downloading Export Templates to ${exportTemplateDownloadPath}...`
)
// If the ZIP file already exists locally, delete it before downloading
if (fs.existsSync(exportTemplateDownloadPath))
fs.rmSync(exportTemplateDownloadPath)
const templateDownloadedPath = await toolsCache.downloadTool(
exportTemplateUrl,
exportTemplateDownloadPath
@ -139,6 +148,11 @@ async function run(platform: Platform): Promise<void> {
// Extract Godot
core.startGroup(`📦 Extracting Godot to ${installationDir}...`)
// If the godot installation folder already exists, remove it before extracting the ZIP file. This will "uninstall" other installations (e.g. on version changes).
if (fs.existsSync(installationDir))
fs.rmdirSync(installationDir, {recursive: true})
const godotExtractedPath = await toolsCache.extractZip(
godotDownloadedPath,
installationDir
@ -159,6 +173,11 @@ async function run(platform: Platform): Promise<void> {
core.startGroup(
`📦 Extracting Export Templates to ${exportTemplatePath}...`
)
// If the export template folder already exists, remove it before extracting the ZIP file. This will "uninstall" other installations (e.g. on version changes).
if (fs.existsSync(exportTemplatePath))
fs.rmdirSync(exportTemplatePath, {recursive: true})
const exportTemplateExtractedPath = await toolsCache.extractZip(
templateDownloadedPath,
path.dirname(exportTemplatePath)
@ -250,6 +269,13 @@ async function run(platform: Platform): Promise<void> {
// Create symlink to Godot executable
const godotAlias = path.join(binDir, 'godot')
core.startGroup(`🔗 Creating symlinks to executables...`)
// If an alias already exists, clear the bin folder before creating the new alias
if (fs.existsSync(binDir)) {
fs.rmSync(binDir, {recursive: true, force: true})
fs.mkdirSync(binDir, {recursive: true})
}
fs.linkSync(godotExecutable, godotAlias)
core.info(`✅ Symlink to Godot created`)
const godotSharpDirAlias = path.join(binDir, 'GodotSharp')