Add osVersion parameter based on ImageOS env variable

d114e80 · Denis Kulicek · 2020-10-28 15:20

5 files +34 -10

Files changed

modified dist/index.js
+16 −4
@@ -2955,9 +2955,9 @@ async function installElixir(version, otpMajor) {
2955 2955 *
2956 2956 * @param {string} version
2957 2957 */
2958 async function installOTP(version) {
2958 +async function installOTP(version, osVersion) {
2959 2959 if (process.platform === 'linux') {
2960 await exec(__webpack_require__.ab + "install-otp", [version])
2960 + await exec(__webpack_require__.ab + "install-otp", [version, osVersion])
2961 2961 return
2962 2962 }
2963 2963
@@ -3321,14 +3321,15 @@ async function main() {
3321 3321 elixirSpec,
3322 3322 otpVersion
3323 3323 )
3324 + const osVersion = getOSVersion()
3324 3325
3325 3326 let installHex = core.getInput('install-hex')
3326 3327 installHex = installHex == null ? 'true' : installHex
3327 3328 let installRebar = core.getInput('install-rebar')
3328 3329 installRebar = installRebar == null ? 'true' : installRebar
3329 3330
3330 console.log(`##[group]Installing OTP ${otpVersion}`)
3331 await installOTP(otpVersion)
3331 + console.log(`##[group]Installing OTP ${otpVersion} - built on ${osVersion}`)
3332 + await installOTP(otpVersion, osVersion)
3332 3333 console.log(`##[endgroup]`)
3333 3334
3334 3335 console.log(`##[group]Installing Elixir ${elixirVersion}`)
@@ -3344,6 +3345,7 @@ async function main() {
3344 3345 console.log(`##[add-matcher]${path.join(matchersPath, 'elixir.json')}`)
3345 3346 core.setOutput('otp-version', otpVersion)
3346 3347 core.setOutput('elixir-version', elixirVersion)
3348 + core.setOutput('osVersion', osVersion)
3347 3349 }
3348 3350
3349 3351 function checkPlatform() {
@@ -3357,6 +3359,16 @@ async function getOtpVersion(spec) {
3357 3359 return getVersionFromSpec(spec, await getOtpVersions()) || spec
3358 3360 }
3359 3361
3362 +function getOSVersion() {
3363 + const mapToUbuntuVersion = {
3364 + ubuntu16: 'ubuntu-16.04',
3365 + ubuntu18: 'ubuntu-18.04',
3366 + ubuntu20: 'ubuntu-20.04',
3367 + }
3368 +
3369 + return mapToUbuntuVersion[process.env.ImageOS] || 'ubuntu-18.04'
3370 +}
3371 +
3360 3372 exports.getElixirVersion = getElixirVersion
3361 3373
3362 3374 async function getElixirVersion(spec, otpVersion) {
modified dist/install-otp
+1 −1
@@ -4,7 +4,7 @@ set -eo pipefail
4 4
5 5 cd $RUNNER_TEMP
6 6
7 wget -q -O otp.tar.gz https://repo.hex.pm/builds/otp/ubuntu-14.04/OTP-${1}.tar.gz
7 +wget -q -O otp.tar.gz https://repo.hex.pm/builds/otp/${2}/OTP-${1}.tar.gz
8 8 mkdir -p .setup-elixir/otp
9 9 tar zxf otp.tar.gz -C .setup-elixir/otp --strip-components=1
10 10 rm otp.tar.gz
modified src/install-otp
+1 −1
@@ -4,7 +4,7 @@ set -eo pipefail
4 4
5 5 cd $RUNNER_TEMP
6 6
7 wget -q -O otp.tar.gz https://repo.hex.pm/builds/otp/ubuntu-14.04/OTP-${1}.tar.gz
7 +wget -q -O otp.tar.gz https://repo.hex.pm/builds/otp/${2}/OTP-${1}.tar.gz
8 8 mkdir -p .setup-elixir/otp
9 9 tar zxf otp.tar.gz -C .setup-elixir/otp --strip-components=1
10 10 rm otp.tar.gz
modified src/installer.js
+2 −2
@@ -22,9 +22,9 @@ async function installElixir(version, otpMajor) {
22 22 *
23 23 * @param {string} version
24 24 */
25 async function installOTP(version) {
25 +async function installOTP(version, osVersion) {
26 26 if (process.platform === 'linux') {
27 await exec(path.join(__dirname, 'install-otp'), [version])
27 + await exec(path.join(__dirname, 'install-otp'), [version, osVersion])
28 28 return
29 29 }
30 30
modified src/setup-elixir.js
+14 −2
@@ -23,14 +23,15 @@ async function main() {
23 23 elixirSpec,
24 24 otpVersion
25 25 )
26 + const osVersion = getOSVersion()
26 27
27 28 let installHex = core.getInput('install-hex')
28 29 installHex = installHex == null ? 'true' : installHex
29 30 let installRebar = core.getInput('install-rebar')
30 31 installRebar = installRebar == null ? 'true' : installRebar
31 32
32 console.log(`##[group]Installing OTP ${otpVersion}`)
33 await installOTP(otpVersion)
33 + console.log(`##[group]Installing OTP ${otpVersion} - built on ${osVersion}`)
34 + await installOTP(otpVersion, osVersion)
34 35 console.log(`##[endgroup]`)
35 36
36 37 console.log(`##[group]Installing Elixir ${elixirVersion}`)
@@ -46,6 +47,7 @@ async function main() {
46 47 console.log(`##[add-matcher]${path.join(matchersPath, 'elixir.json')}`)
47 48 core.setOutput('otp-version', otpVersion)
48 49 core.setOutput('elixir-version', elixirVersion)
50 + core.setOutput('osVersion', osVersion)
49 51 }
50 52
51 53 function checkPlatform() {
@@ -59,6 +61,16 @@ async function getOtpVersion(spec) {
59 61 return getVersionFromSpec(spec, await getOtpVersions()) || spec
60 62 }
61 63
64 +function getOSVersion() {
65 + const mapToUbuntuVersion = {
66 + ubuntu16: 'ubuntu-16.04',
67 + ubuntu18: 'ubuntu-18.04',
68 + ubuntu20: 'ubuntu-20.04',
69 + }
70 +
71 + return mapToUbuntuVersion[process.env.ImageOS] || 'ubuntu-18.04'
72 +}
73 +
62 74 exports.getElixirVersion = getElixirVersion
63 75
64 76 async function getElixirVersion(spec, otpVersion) {

Parents: 5841733