Skip to content

Commit

Permalink
Resolving issues with Self-Hosted GitHub Runners and local caches (#71)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
SakulFlee authored Jan 30, 2024
1 parent 1af6893 commit d3fbddf
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
17 changes: 17 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit d3fbddf

Please sign in to comment.