mirror of
				https://github.com/chickensoft-games/setup-godot.git
				synced 2025-10-31 19:33:56 +00:00 
			
		
		
		
	Add include-templates option (default false). Fix cache. (#80)
* Add include-templates option (default false). Fix cache failing to resolve. * Update readme about optional templates. * Add include-templates as part of test matrix * Fix include-templates matrix
This commit is contained in:
		
							parent
							
								
									d3fbddfbaf
								
							
						
					
					
						commit
						1dc3741f47
					
				
							
								
								
									
										4
									
								
								.github/workflows/test.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.github/workflows/test.yml
									
									
									
									
										vendored
									
									
								
							| @ -16,7 +16,7 @@ on: | ||||
| 
 | ||||
| jobs: | ||||
|   tests: | ||||
|     name: 🧪 Test on ${{ matrix.os }}, .NET=${{ matrix.use-dotnet }} | ||||
|     name: 🧪 Test on ${{ matrix.os }}, .NET=${{ matrix.use-dotnet }}, include-templates=${{ matrix.include-templates }} | ||||
|     if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name | ||||
|     runs-on: ${{ matrix.os }} | ||||
|     strategy: | ||||
| @ -26,6 +26,7 @@ jobs: | ||||
|         # Put the operating systems you want to run on here. | ||||
|         os: [ubuntu-latest, macos-latest, windows-latest] | ||||
|         use-dotnet: [false, true] | ||||
|         include-templates: [false, true] | ||||
|     env: | ||||
|       DOTNET_CLI_TELEMETRY_OPTOUT: true | ||||
|       DOTNET_NOLOGO: true | ||||
| @ -50,6 +51,7 @@ jobs: | ||||
|           # Pre-release label is optional. | ||||
|           version: 4.0.0 | ||||
|           use-dotnet: ${{ matrix.use-dotnet }} | ||||
|           include-templates: ${{ matrix.include-templates }} | ||||
| 
 | ||||
|       - name: 🔬 Verify Dotnet | ||||
|         if: ${{ matrix.use-dotnet }} | ||||
|  | ||||
| @ -5,7 +5,7 @@ | ||||
| Setup Godot for use with (or without) .NET on macOS, Windows, and Linux CI/CD runners. | ||||
| 
 | ||||
| - ✅ Installs Godot 4.x | ||||
| - ✅ Installs export templates. | ||||
| - ✅ Optionally installs export templates. | ||||
| - ✅ C# supported using .NET version of Godot. | ||||
| - ✅ Versions **without** .NET are also supported. | ||||
| - ✅ Installs Godot directly on the CI/CD runner. | ||||
| @ -63,6 +63,8 @@ jobs: | ||||
|           version: 4.0.0-beta16 # also valid: 4.0.0.rc1 or 4.0.0, etc | ||||
|           # Use .NET-enabled version of Godot (the default is also true). | ||||
|           use-dotnet: true | ||||
|           # Include the Godot Export Templtes (the default is false). | ||||
|           include-templates: true | ||||
| 
 | ||||
|       - name: 🔬 Verify Setup | ||||
|         run: | | ||||
|  | ||||
| @ -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' | ||||
|  | ||||
							
								
								
									
										35
									
								
								dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										35
									
								
								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}`); | ||||
|         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,6 +152,14 @@ function run(platform) { | ||||
|                 executables = yield (0, utils_1.findExecutablesRecursively)(platform, installationDir, ''); | ||||
|                 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)) | ||||
| @ -165,9 +174,10 @@ function run(platform) { | ||||
|                     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
											
										
									
								
							
							
								
								
									
										60
									
								
								src/main.ts
									
									
									
									
									
								
							
							
						
						
									
										60
									
								
								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}`) | ||||
|    | ||||
|   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,6 +166,24 @@ async function run(platform: Platform): Promise<void> { | ||||
|       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 = await toolsCache.downloadTool( | ||||
|           exportTemplateUrl, | ||||
|           exportTemplateDownloadPath | ||||
|         ) | ||||
|         core.info(`✅ Export Templates downloaded to ${templateDownloadedPath}`) | ||||
|         core.endGroup() | ||||
| 
 | ||||
| 
 | ||||
|         core.startGroup( | ||||
|           `📦 Extracting Export Templates to ${exportTemplatePath}...` | ||||
|         ) | ||||
| @ -202,12 +216,13 @@ async function run(platform: Platform): Promise<void> { | ||||
|         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