Skip to content

Commit

Permalink
Rename archives to .zip to make extraction work on old PowerShell ver…
Browse files Browse the repository at this point in the history
…sions (#43)
  • Loading branch information
Vampire committed Jan 24, 2023
1 parent a00ad19 commit c6e8c2a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/main/kotlin/net/kautler/github/action/setup_wsl/SetupWsl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import getInput as coreGetInput
import isDebug as coreIsDebug
import isFeatureAvailable as cacheIsFeatureAvailable
import mkdirP as ioMkdirP
import mv as ioMv
import restoreCache as cacheRestoreCache
import saveCache as cacheSaveCache
import setFailed as coreSetFailed
Expand Down Expand Up @@ -177,13 +178,13 @@ val distributionDirectory = GlobalScope.async(start = LAZY) {
}

val distributionDownload = toolCacheDownloadTool("${distribution.downloadUrl()}").await()
var extractedDistributionDirectory = toolCacheExtractZip(distributionDownload).await()
var extractedDistributionDirectory = extractZip(distributionDownload)

if (!existsSync(path.join(extractedDistributionDirectory, distribution.installerFile))) {
extractedDistributionDirectory = readdirSync(extractedDistributionDirectory, jsObject<`T$35`>())
.asFlow()
.filter { it.contains("""(?<!_(?:scale-(?:100|125|150|400)|ARM64))\.appx$""".toRegex()) }
.map { toolCacheExtractZip(path.join(extractedDistributionDirectory, it)).await() }
.map { extractZip(path.join(extractedDistributionDirectory, it)) }
.firstOrNull { existsSync(path.join(it, distribution.installerFile)) }
?: error("'${distribution.installerFile}' not found for distribution '${distribution.userId}'")
}
Expand Down Expand Up @@ -296,6 +297,13 @@ suspend fun main() {
}
}

suspend fun extractZip(archive: String): String {
// work-around for https://github.com/actions/toolkit/issues/1319
val archiveZip = "$archive.zip"
ioMv(archive, archiveZip).await()
return toolCacheExtractZip(archiveZip).await()
}

suspend fun executeWslCommand(
wslArguments: Array<String>,
wslconfigArguments: Array<String>? = null
Expand Down

0 comments on commit c6e8c2a

Please sign in to comment.