mirror of
				https://github.com/chickensoft-games/setup-godot.git
				synced 2025-10-31 23:43:55 +00:00 
			
		
		
		
	Add include-templates option (default false). Fix cache failing to resolve.
This commit is contained in:
		
							parent
							
								
									d3fbddfbaf
								
							
						
					
					
						commit
						8ef2633da9
					
				| @ -61,7 +61,11 @@ inputs: | ||||
|   use-dotnet: | ||||
|     description: >- | ||||
|       True to use the .NET-enabled version of Godot that enables C#, false to use the default version. | ||||
|     default: 'true' | ||||
|     default: true | ||||
|   include-templates: | ||||
|     description: >- | ||||
|       True will also download the Godot Export Templates for each platform. | ||||
|     default: false | ||||
| runs: | ||||
|   using: 'node16' | ||||
|   main: 'dist/index.js' | ||||
|  | ||||
							
								
								
									
										69
									
								
								dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										69
									
								
								dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							| @ -62,6 +62,7 @@ function run(platform) { | ||||
|         const binRelativePath = core.getInput('bin-path').replace(/\s/g, ''); | ||||
|         const godotSharpRelease = core.getBooleanInput('godot-sharp-release'); | ||||
|         const checkoutDirectory = (_a = process.env['GITHUB_WORKSPACE']) !== null && _a !== void 0 ? _a : ''; | ||||
|         const includeTemplates = core.getBooleanInput('include-templates'); | ||||
|         const userDir = os.homedir(); | ||||
|         const downloadsDir = path_1.default.join(userDir, downloadsRelativePath); | ||||
|         const installationDir = path_1.default.join(userDir, pathRelative); | ||||
| @ -90,9 +91,9 @@ function run(platform) { | ||||
|         const godotDownloadPath = path_1.default.join(downloadsDir, `${versionName}.zip`); | ||||
|         const godotInstallationPath = platform.getUnzippedPath(installationDir, versionName, useDotnet); | ||||
|         const binDir = path_1.default.join(userDir, binRelativePath); | ||||
|         const exportTemplateUrl = (0, utils_1.getGodotUrl)(version, platform, useDotnet, true); | ||||
|         const exportTemplatePath = (0, utils_1.getExportTemplatePath)(version, platform, useDotnet); | ||||
|         const exportTemplateDownloadPath = path_1.default.join(downloadsDir, 'export_templates.zip'); | ||||
|         const exportTemplateUrl = includeTemplates ? (0, utils_1.getGodotUrl)(version, platform, useDotnet, true) : ''; | ||||
|         const exportTemplatePath = includeTemplates ? (0, utils_1.getExportTemplatePath)(version, platform, useDotnet) : ''; | ||||
|         const exportTemplateDownloadPath = includeTemplates ? path_1.default.join(downloadsDir, 'export_templates.zip') : ''; | ||||
|         core.info(`🤖 Godot version: ${version}`); | ||||
|         core.info(`🤖 Godot version name: ${versionName}`); | ||||
|         core.info(`🟣 Use .NET: ${useDotnet}`); | ||||
| @ -102,9 +103,14 @@ function run(platform) { | ||||
|         core.info(`📥 Godot download path: ${godotDownloadPath}`); | ||||
|         core.info(`📦 Godot installation directory: ${installationDir}`); | ||||
|         core.info(`🤖 Godot installation path: ${godotInstallationPath}`); | ||||
|         core.info(`🤖 Export Template url: ${exportTemplateUrl}`); | ||||
|         core.info(`📥 Export Template download path: ${exportTemplateDownloadPath}`); | ||||
|         core.info(`🤖 Export Template Path: ${exportTemplatePath}`); | ||||
|         if (includeTemplates) { | ||||
|             core.info(`🤖 Export Template url: ${exportTemplateUrl}`); | ||||
|             core.info(`📥 Export Template download path: ${exportTemplateDownloadPath}`); | ||||
|             core.info(`🤖 Export Template Path: ${exportTemplatePath}`); | ||||
|         } | ||||
|         else { | ||||
|             core.info(`⏭️ Skipping Export Templates.`); | ||||
|         } | ||||
|         core.info(`📂 Bin directory: ${binDir}`); | ||||
|         core.info(`🤖 GodotSharp release: ${godotSharpRelease}`); | ||||
|         core.endGroup(); | ||||
| @ -118,7 +124,9 @@ function run(platform) { | ||||
|             core.endGroup(); | ||||
|             // See if Godot is already installed.
 | ||||
|             core.startGroup(`🤔 Checking if Godot is already in cache...`); | ||||
|             const cached = yield cache.restoreCache([godotInstallationPath, exportTemplatePath], godotUrl); | ||||
|             const cachedPaths = includeTemplates ? [godotInstallationPath, exportTemplatePath] : [godotInstallationPath]; | ||||
|             const cacheKey = includeTemplates ? godotUrl : godotUrl + '-no-templates'; | ||||
|             const cached = yield cache.restoreCache(cachedPaths.slice(), cacheKey); | ||||
|             let executables; | ||||
|             if (!cached) { | ||||
|                 // Download Godot
 | ||||
| @ -131,13 +139,6 @@ function run(platform) { | ||||
|                 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).
 | ||||
| @ -151,23 +152,32 @@ function run(platform) { | ||||
|                 executables = yield (0, utils_1.findExecutablesRecursively)(platform, installationDir, ''); | ||||
|                 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); | ||||
|                 core.info(`✅ ${path_1.default.join(path_1.default.dirname(exportTemplateExtractedPath), 'templates')} moved to ${exportTemplatePath}`); | ||||
|                 core.endGroup(); | ||||
|                 // Show extracted Export Template files recursively
 | ||||
|                 core.startGroup(`📄 Showing extracted files recursively...`); | ||||
|                 yield (0, utils_1.findExecutablesRecursively)(platform, exportTemplatePath, ''); | ||||
|                 core.info(`✅ Files shown`); | ||||
|                 core.endGroup(); | ||||
|                 if (includeTemplates) { | ||||
|                     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(); | ||||
|                     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); | ||||
|                     core.info(`✅ ${path_1.default.join(path_1.default.dirname(exportTemplateExtractedPath), 'templates')} moved to ${exportTemplatePath}`); | ||||
|                     core.endGroup(); | ||||
|                     // Show extracted Export Template files recursively
 | ||||
|                     core.startGroup(`📄 Showing extracted files recursively...`); | ||||
|                     yield (0, utils_1.findExecutablesRecursively)(platform, exportTemplatePath, ''); | ||||
|                     core.info(`✅ Files shown`); | ||||
|                     core.endGroup(); | ||||
|                 } | ||||
|                 // Save extracted Godot contents to cache
 | ||||
|                 core.startGroup(`💾 Saving extracted Godot download to cache...`); | ||||
|                 yield cache.saveCache([godotInstallationPath, exportTemplatePath], godotUrl); | ||||
|                 yield cache.saveCache(cachedPaths, cacheKey); | ||||
|                 core.info(`✅ Godot saved to cache`); | ||||
|                 core.endGroup(); | ||||
|             } | ||||
| @ -176,7 +186,6 @@ function run(platform) { | ||||
|                 core.endGroup(); | ||||
|                 core.startGroup(`📄 Showing cached files recursively...`); | ||||
|                 executables = yield (0, utils_1.findExecutablesRecursively)(platform, installationDir, ''); | ||||
|                 yield (0, utils_1.findExecutablesRecursively)(platform, exportTemplatePath, ''); | ||||
|                 core.info(`✅ Files shown`); | ||||
|                 core.endGroup(); | ||||
|             } | ||||
|  | ||||
							
								
								
									
										2
									
								
								dist/index.js.map
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								dist/index.js.map
									
									
									
										generated
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										124
									
								
								src/main.ts
									
									
									
									
									
								
							
							
						
						
									
										124
									
								
								src/main.ts
									
									
									
									
									
								
							| @ -25,6 +25,7 @@ async function run(platform: Platform): Promise<void> { | ||||
|   const binRelativePath = core.getInput('bin-path').replace(/\s/g, '') | ||||
|   const godotSharpRelease = core.getBooleanInput('godot-sharp-release') | ||||
|   const checkoutDirectory = process.env['GITHUB_WORKSPACE'] ?? '' | ||||
|   const includeTemplates = core.getBooleanInput('include-templates') | ||||
| 
 | ||||
|   const userDir = os.homedir() | ||||
|   const downloadsDir = path.join(userDir, downloadsRelativePath) | ||||
| @ -74,12 +75,12 @@ async function run(platform: Platform): Promise<void> { | ||||
|   ) | ||||
|   const binDir = path.join(userDir, binRelativePath) | ||||
| 
 | ||||
|   const exportTemplateUrl = getGodotUrl(version, platform, useDotnet, true) | ||||
|   const exportTemplatePath = getExportTemplatePath(version, platform, useDotnet) | ||||
|   const exportTemplateDownloadPath = path.join( | ||||
|   const exportTemplateUrl = includeTemplates ? getGodotUrl(version, platform, useDotnet, true) : '' | ||||
|   const exportTemplatePath = includeTemplates ? getExportTemplatePath(version, platform, useDotnet) : '' | ||||
|   const exportTemplateDownloadPath = includeTemplates ? path.join( | ||||
|     downloadsDir, | ||||
|     'export_templates.zip' | ||||
|   ) | ||||
|   ) : '' | ||||
| 
 | ||||
|   core.info(`🤖 Godot version: ${version}`) | ||||
|   core.info(`🤖 Godot version name: ${versionName}`) | ||||
| @ -90,9 +91,15 @@ async function run(platform: Platform): Promise<void> { | ||||
|   core.info(`📥 Godot download path: ${godotDownloadPath}`) | ||||
|   core.info(`📦 Godot installation directory: ${installationDir}`) | ||||
|   core.info(`🤖 Godot installation path: ${godotInstallationPath}`) | ||||
|   core.info(`🤖 Export Template url: ${exportTemplateUrl}`) | ||||
|   core.info(`📥 Export Template download path: ${exportTemplateDownloadPath}`) | ||||
|   core.info(`🤖 Export Template Path: ${exportTemplatePath}`) | ||||
|    | ||||
|   if (includeTemplates) { | ||||
|     core.info(`🤖 Export Template url: ${exportTemplateUrl}`) | ||||
|     core.info(`📥 Export Template download path: ${exportTemplateDownloadPath}`) | ||||
|     core.info(`🤖 Export Template Path: ${exportTemplatePath}`) | ||||
|   } else { | ||||
|     core.info(`⏭️ Skipping Export Templates.`) | ||||
|   } | ||||
|    | ||||
|   core.info(`📂 Bin directory: ${binDir}`) | ||||
|   core.info(`🤖 GodotSharp release: ${godotSharpRelease}`) | ||||
|   core.endGroup() | ||||
| @ -108,9 +115,12 @@ async function run(platform: Platform): Promise<void> { | ||||
| 
 | ||||
|     // See if Godot is already installed.
 | ||||
|     core.startGroup(`🤔 Checking if Godot is already in cache...`) | ||||
|      | ||||
|     const cachedPaths = includeTemplates ? [ godotInstallationPath, exportTemplatePath] : [ godotInstallationPath ] | ||||
|     const cacheKey = includeTemplates ? godotUrl : godotUrl + '-no-templates' | ||||
|     const cached = await cache.restoreCache( | ||||
|       [godotInstallationPath, exportTemplatePath], | ||||
|       godotUrl | ||||
|       cachedPaths.slice(), | ||||
|       cacheKey | ||||
|     ) | ||||
| 
 | ||||
|     let executables: string[] | ||||
| @ -131,20 +141,6 @@ async function run(platform: Platform): Promise<void> { | ||||
|       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 = await toolsCache.downloadTool( | ||||
|         exportTemplateUrl, | ||||
|         exportTemplateDownloadPath | ||||
|       ) | ||||
|       core.info(`✅ Export Templates downloaded to ${templateDownloadedPath}`) | ||||
|       core.endGroup() | ||||
| 
 | ||||
|       // Extract Godot
 | ||||
|       core.startGroup(`📦 Extracting Godot to ${installationDir}...`) | ||||
| @ -170,44 +166,63 @@ async function run(platform: Platform): Promise<void> { | ||||
|       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}) | ||||
|       if (includeTemplates) { | ||||
|         core.startGroup( | ||||
|           `📥 Downloading Export Templates to ${exportTemplateDownloadPath}...` | ||||
|         ) | ||||
| 
 | ||||
|       const exportTemplateExtractedPath = await toolsCache.extractZip( | ||||
|         templateDownloadedPath, | ||||
|         path.dirname(exportTemplatePath) | ||||
|       ) | ||||
|       core.info( | ||||
|         `✅ Export Templates extracted to ${exportTemplateExtractedPath}` | ||||
|       ) | ||||
|       fs.renameSync( | ||||
|         path.join(exportTemplateExtractedPath, 'templates'), | ||||
|         exportTemplatePath | ||||
|       ) | ||||
|       core.info( | ||||
|         `✅ ${path.join( | ||||
|           path.dirname(exportTemplateExtractedPath), | ||||
|           'templates' | ||||
|         )} moved to ${exportTemplatePath}` | ||||
|       ) | ||||
|       core.endGroup() | ||||
|         // If the ZIP file already exists locally, delete it before downloading
 | ||||
|         if (fs.existsSync(exportTemplateDownloadPath)) | ||||
|           fs.rmSync(exportTemplateDownloadPath) | ||||
| 
 | ||||
|       // Show extracted Export Template files recursively
 | ||||
|       core.startGroup(`📄 Showing extracted files recursively...`) | ||||
|       await findExecutablesRecursively(platform, exportTemplatePath, '') | ||||
|       core.info(`✅ Files shown`) | ||||
|       core.endGroup() | ||||
|         const templateDownloadedPath = await toolsCache.downloadTool( | ||||
|           exportTemplateUrl, | ||||
|           exportTemplateDownloadPath | ||||
|         ) | ||||
|         core.info(`✅ Export Templates downloaded to ${templateDownloadedPath}`) | ||||
|         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 = await toolsCache.extractZip( | ||||
|           templateDownloadedPath, | ||||
|           path.dirname(exportTemplatePath) | ||||
|         ) | ||||
|         core.info( | ||||
|           `✅ Export Templates extracted to ${exportTemplateExtractedPath}` | ||||
|         ) | ||||
|         fs.renameSync( | ||||
|           path.join(exportTemplateExtractedPath, 'templates'), | ||||
|           exportTemplatePath | ||||
|         ) | ||||
|         core.info( | ||||
|           `✅ ${path.join( | ||||
|             path.dirname(exportTemplateExtractedPath), | ||||
|             'templates' | ||||
|           )} moved to ${exportTemplatePath}` | ||||
|         ) | ||||
|         core.endGroup() | ||||
| 
 | ||||
|         // Show extracted Export Template files recursively
 | ||||
|         core.startGroup(`📄 Showing extracted files recursively...`) | ||||
|         await findExecutablesRecursively(platform, exportTemplatePath, '') | ||||
|         core.info(`✅ Files shown`) | ||||
|         core.endGroup() | ||||
|       } | ||||
| 
 | ||||
|       // Save extracted Godot contents to cache
 | ||||
|       core.startGroup(`💾 Saving extracted Godot download to cache...`) | ||||
|       await cache.saveCache( | ||||
|         [godotInstallationPath, exportTemplatePath], | ||||
|         godotUrl | ||||
|         cachedPaths, | ||||
|         cacheKey | ||||
|       ) | ||||
|       core.info(`✅ Godot saved to cache`) | ||||
|       core.endGroup() | ||||
| @ -221,7 +236,6 @@ async function run(platform: Platform): Promise<void> { | ||||
|         installationDir, | ||||
|         '' | ||||
|       ) | ||||
|       await findExecutablesRecursively(platform, exportTemplatePath, '') | ||||
|       core.info(`✅ Files shown`) | ||||
|       core.endGroup() | ||||
|     } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user