@@ -3,17 +3,19 @@ import * as tc from '@actions/tool-cache'
3
3
4
4
import * as fs from 'fs'
5
5
import * as https from 'https'
6
+ import * as os from 'os'
6
7
import * as path from 'path'
7
8
8
9
import * as installer from './installer'
9
10
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.
10
15
const archSynonyms = {
11
16
'x86' : 'x86' ,
12
- 'X86' : 'x86' ,
13
17
'x64' : 'x64' ,
14
- 'X64' : 'x64' ,
15
18
'aarch64' : 'aarch64' ,
16
- 'ARM64' : 'aarch64' ,
17
19
'arm64' : 'aarch64'
18
20
}
19
21
@@ -37,24 +39,37 @@ async function run() {
37
39
} )
38
40
}
39
41
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 ( )
44
47
45
48
// It can easily happen that, for example, a workflow file contains an input `version: ${{ matrix.julia-version }}`
46
49
// while the strategy matrix only contains a key `${{ matrix.version }}`.
47
50
// In that case, we want the action to fail, rather than trying to download julia from an URL that's missing parts and 404ing.
48
51
// We _could_ fall back to the default but that means that builds silently do things differently than they're meant to, which
49
52
// is worse than failing the build.
50
- if ( ! versionInput ) {
53
+ if ( ! versionInput ) { // if `versionInput` is an empty string
51
54
throw new Error ( 'Version input must not be null' )
52
55
}
53
- if ( ! originalArchInput ) {
56
+ if ( ! originalArchInput ) { // if `originalArchInput` is an empty string
54
57
throw new Error ( `Arch input must not be null` )
55
58
}
56
59
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 } ` )
58
73
59
74
const versionInfo = await installer . getJuliaVersionInfo ( )
60
75
const availableReleases = await installer . getJuliaVersions ( versionInfo )
0 commit comments