Install OTP on Windows to a local directory (#139)

7dd0d76 · Wojtek Mach · 2022-09-12 14:40

6 files +12 -40

Files changed

modified dist/index.js
+1 −10
@@ -7173,7 +7173,6 @@ const { exec } = __nccwpck_require__(1514)
7173 7173 const path = __nccwpck_require__(1017)
7174 7174 const semver = __nccwpck_require__(1383)
7175 7175 const https = __nccwpck_require__(5687)
7176 const fs = __nccwpck_require__(7147)
7177 7176 const installer = __nccwpck_require__(2127)
7178 7177
7179 7178 main().catch((err) => {
@@ -7218,15 +7217,7 @@ async function installOTP(otpSpec, osVersion) {
7218 7217 )
7219 7218 await installer.installOTP(osVersion, otpVersion)
7220 7219 core.setOutput('otp-version', otpVersion)
7221 if (process.platform === 'linux') {
7222 core.addPath(`${process.env.RUNNER_TEMP}/.setup-beam/otp/bin`)
7223 } else if (process.platform === 'win32') {
7224 const otpPath = fs.readFileSync(`${process.env.RUNNER_TEMP}/otp_path.txt`, {
7225 encoding: 'utf8',
7226 flag: 'r',
7227 })
7228 core.addPath(otpPath)
7229 }
7220 + core.addPath(`${process.env.RUNNER_TEMP}/.setup-beam/otp/bin`)
7230 7221 console.log('##[endgroup]')
7231 7222
7232 7223 return otpVersion
modified dist/install-otp.ps1
+4 −9
@@ -5,18 +5,13 @@ $ErrorActionPreference="Stop"
5 5 Set-Location ${Env:RUNNER_TEMP}
6 6
7 7 $FILE_OUTPUT="otp.exe"
8 $DIR_FOR_BIN=".setup-beam/otp"
8 +$ERL_ROOT = "${Env:RUNNER_TEMP}\.setup-beam\otp"
9 9
10 10 $ProgressPreference="SilentlyContinue"
11 11 Invoke-WebRequest "https://github.com/erlang/otp/releases/download/OTP-${VSN}/otp_win64_${VSN}.exe" -OutFile "${FILE_OUTPUT}"
12 12 $ProgressPreference="Continue"
13 New-Item "${DIR_FOR_BIN}" -ItemType Directory | Out-Null
14 Move-Item "${FILE_OUTPUT}" "${DIR_FOR_BIN}"
15 Start-Process "./${DIR_FOR_BIN}/${FILE_OUTPUT}" /S -Wait
16 $ErlExec = Get-ChildItem -Path "C:/Program Files/" -Recurse -Depth 2 -Filter 'erl.exe' -Name | ForEach-Object { Write-Output "C:/Program Files/$_" }
17 $ErlPath = Split-Path -Path "${ErlExec}"
18 Write-Output "${ErlPath}" | Out-File -FilePath otp_path.txt -Encoding utf8 -NoNewline
13 +Start-Process "${FILE_OUTPUT}" "/S /D=${ERL_ROOT}" -Wait
19 14 Write-Output "Installed Erlang/OTP version follows"
20 & "${ErlPath}/erl.exe" "+V" | Write-Output
15 +& "${ERL_ROOT}/bin/erl.exe" "+V" | Write-Output
21 16
22 "INSTALL_DIR_FOR_OTP="+(Get-Item ${ErlPath}).parent.FullName | Out-File -FilePath ${Env:GITHUB_ENV} -Encoding utf8 -Append
17 +"INSTALL_DIR_FOR_OTP=" + ${ERL_ROOT}
modified dist/install-otp.sh
+1 −1
@@ -17,4 +17,4 @@ tar zxf "${FILE_OUTPUT}" -C "${DIR_FOR_BIN}" --strip-components=1
17 17 echo "Installed Erlang/OTP version follows"
18 18 ${DIR_FOR_BIN}/bin/erl -version
19 19
20 echo "INSTALL_DIR_FOR_OTP=${RUNNER_TEMP}/${DIR_FOR_BIN}" >> "${GITHUB_ENV}"
20 +echo "INSTALL_DIR_FOR_OTP=${RUNNER_TEMP}/${DIR_FOR_BIN}"
modified src/install-otp.ps1
+4 −9
@@ -5,18 +5,13 @@ $ErrorActionPreference="Stop"
5 5 Set-Location ${Env:RUNNER_TEMP}
6 6
7 7 $FILE_OUTPUT="otp.exe"
8 $DIR_FOR_BIN=".setup-beam/otp"
8 +$ERL_ROOT = "${Env:RUNNER_TEMP}\.setup-beam\otp"
9 9
10 10 $ProgressPreference="SilentlyContinue"
11 11 Invoke-WebRequest "https://github.com/erlang/otp/releases/download/OTP-${VSN}/otp_win64_${VSN}.exe" -OutFile "${FILE_OUTPUT}"
12 12 $ProgressPreference="Continue"
13 New-Item "${DIR_FOR_BIN}" -ItemType Directory | Out-Null
14 Move-Item "${FILE_OUTPUT}" "${DIR_FOR_BIN}"
15 Start-Process "./${DIR_FOR_BIN}/${FILE_OUTPUT}" /S -Wait
16 $ErlExec = Get-ChildItem -Path "C:/Program Files/" -Recurse -Depth 2 -Filter 'erl.exe' -Name | ForEach-Object { Write-Output "C:/Program Files/$_" }
17 $ErlPath = Split-Path -Path "${ErlExec}"
18 Write-Output "${ErlPath}" | Out-File -FilePath otp_path.txt -Encoding utf8 -NoNewline
13 +Start-Process "${FILE_OUTPUT}" "/S /D=${ERL_ROOT}" -Wait
19 14 Write-Output "Installed Erlang/OTP version follows"
20 & "${ErlPath}/erl.exe" "+V" | Write-Output
15 +& "${ERL_ROOT}/bin/erl.exe" "+V" | Write-Output
21 16
22 "INSTALL_DIR_FOR_OTP="+(Get-Item ${ErlPath}).parent.FullName | Out-File -FilePath ${Env:GITHUB_ENV} -Encoding utf8 -Append
17 +"INSTALL_DIR_FOR_OTP=" + ${ERL_ROOT}
modified src/install-otp.sh
+1 −1
@@ -17,4 +17,4 @@ tar zxf "${FILE_OUTPUT}" -C "${DIR_FOR_BIN}" --strip-components=1
17 17 echo "Installed Erlang/OTP version follows"
18 18 ${DIR_FOR_BIN}/bin/erl -version
19 19
20 echo "INSTALL_DIR_FOR_OTP=${RUNNER_TEMP}/${DIR_FOR_BIN}" >> "${GITHUB_ENV}"
20 +echo "INSTALL_DIR_FOR_OTP=${RUNNER_TEMP}/${DIR_FOR_BIN}"
modified src/setup-beam.js
+1 −10
@@ -3,7 +3,6 @@ const { exec } = require('@actions/exec')
3 3 const path = require('path')
4 4 const semver = require('semver')
5 5 const https = require('https')
6 const fs = require('fs')
7 6 const installer = require('./installer')
8 7
9 8 main().catch((err) => {
@@ -48,15 +47,7 @@ async function installOTP(otpSpec, osVersion) {
48 47 )
49 48 await installer.installOTP(osVersion, otpVersion)
50 49 core.setOutput('otp-version', otpVersion)
51 if (process.platform === 'linux') {
52 core.addPath(`${process.env.RUNNER_TEMP}/.setup-beam/otp/bin`)
53 } else if (process.platform === 'win32') {
54 const otpPath = fs.readFileSync(`${process.env.RUNNER_TEMP}/otp_path.txt`, {
55 encoding: 'utf8',
56 flag: 'r',
57 })
58 core.addPath(otpPath)
59 }
50 + core.addPath(`${process.env.RUNNER_TEMP}/.setup-beam/otp/bin`)
60 51 console.log('##[endgroup]')
61 52
62 53 return otpVersion

Parents: ee0fa0b