@@ -3,17 +3,19 @@ import * as tc from '@actions/tool-cache'
33
44import * as fs from 'fs'
55import * as https from 'https'
6+ import * as os from 'os'
67import * as path from 'path'
78
89import * as installer from './installer'
910
11+ // Note: before we index into this dict, we always first do `.toLowerCase()` on
12+ // the key.
13+ //
14+ // Therefore, this dict does not need to account for differences in case.
1015const archSynonyms = {
1116 'x86' : 'x86' ,
12- 'X86' : 'x86' ,
1317 'x64' : 'x64' ,
14- 'X64' : 'x64' ,
1518 'aarch64' : 'aarch64' ,
16- 'ARM64' : 'aarch64' ,
1719 'arm64' : 'aarch64'
1820}
1921
@@ -37,24 +39,37 @@ async function run() {
3739 } )
3840 }
3941
40- // Inputs
41- const versionInput = core . getInput ( 'version' )
42- const includePrereleases = core . getInput ( 'include-all-prereleases' ) == 'true'
43- const originalArchInput = core . getInput ( 'arch' )
42+ // Inputs.
43+ // Note that we intentionally strip leading and lagging whitespace by using `.trim()`
44+ const versionInput = core . getInput ( 'version' ) . trim ( )
45+ const includePrereleases = core . getInput ( 'include-all-prereleases' ) . trim ( ) == 'true'
46+ const originalArchInput = core . getInput ( 'arch' ) . trim ( )
4447
4548 // It can easily happen that, for example, a workflow file contains an input `version: ${{ matrix.julia-version }}`
4649 // while the strategy matrix only contains a key `${{ matrix.version }}`.
4750 // In that case, we want the action to fail, rather than trying to download julia from an URL that's missing parts and 404ing.
4851 // We _could_ fall back to the default but that means that builds silently do things differently than they're meant to, which
4952 // is worse than failing the build.
50- if ( ! versionInput ) {
53+ if ( ! versionInput ) { // if `versionInput` is an empty string
5154 throw new Error ( 'Version input must not be null' )
5255 }
53- if ( ! originalArchInput ) {
56+ if ( ! originalArchInput ) { // if `originalArchInput` is an empty string
5457 throw new Error ( `Arch input must not be null` )
5558 }
5659
57- const arch = archSynonyms [ originalArchInput ]
60+ let processedArchInput : string ;
61+ if ( originalArchInput == "default" ) {
62+ // If the user sets the `arch` input to `default`, then we use the
63+ // architecture of the machine that we are running on.
64+ processedArchInput = os . arch ( ) ;
65+ core . debug ( `The "arch" input is "default", so we will use the machine arch: ${ processedArchInput } ` )
66+ } else {
67+ processedArchInput = originalArchInput ;
68+ }
69+ // Note: we convert the key `processedArchInput` to lower case
70+ // before we index into the `archSynonyms` dict.
71+ const arch = archSynonyms [ processedArchInput . toLowerCase ( ) ]
72+ core . debug ( `Mapped the "arch" from ${ processedArchInput } to ${ arch } ` )
5873
5974 const versionInfo = await installer . getJuliaVersionInfo ( )
6075 const availableReleases = await installer . getJuliaVersions ( versionInfo )
0 commit comments