Skip to content

Commit

Permalink
Export Paths to Environmental Variables (#451)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmitch215 authored Nov 12, 2024
1 parent 6bc822d commit d3ed6e6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
13 changes: 11 additions & 2 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.

16 changes: 14 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,18 @@ async function run(): Promise<void> {
const ktPath = await tc.downloadTool(
`https://github.com/JetBrains/kotlin/releases/download/v${version}/kotlin-compiler-${version}.zip`.replace('\n', '')
)
core.debug(`Downloaded Kotlin ${version} to ${ktPath}`)

const ktPathExtractedFolder = await tc.extractZip(ktPath)

cachedPath = await tc.cacheDir(ktPathExtractedFolder, 'kotlin', version)

if (!nativeCachedPath) {
if (installNative) {
const ktNativePath = await tc.downloadTool(nativeDownloadUrl(version))
core.debug(`Downloaded Kotlin Native ${version} to ${ktNativePath}`)
core.exportVariable('KOTLIN_NATIVE_HOME', ktNativePath)

const ktNativePathExtractedFolder = await extractNativeArchive(ktNativePath)
nativeCachedPath = await tc.cacheDir(ktNativePathExtractedFolder, 'kotlin-native', version)
}
Expand All @@ -40,10 +45,17 @@ async function run(): Promise<void> {
The order of addPath call here matter because both archives have a "kotlinc" binary.
*/
if (installNative) {
core.addPath(`${nativeCachedPath}/kotlin-native-prebuilt-${osName()}-${osArch()}-${version}/bin`)
const nativePath = `${nativeCachedPath}/kotlin-native-prebuilt-${osName()}-${osArch()}-${version}`
core.addPath(`${nativePath}/bin`)
core.exportVariable('KOTLIN_NATIVE_HOME', nativePath)
core.debug(`Added ${nativePath}/bin to PATH`)
await exec.exec('kotlinc-native', ['-version'])
}
core.addPath(`${cachedPath}/kotlinc/bin`)

const kotlinPath = `${cachedPath}/kotlinc`
core.addPath(`${kotlinPath}/bin`)
core.exportVariable('KOTLIN_HOME', kotlinPath)
core.debug(`Added ${kotlinPath}/bin to PATH`)
await exec.exec('kotlinc', ['-version'])

const script = core.getInput('script')
Expand Down

0 comments on commit d3ed6e6

Please sign in to comment.