@@ -2,8 +2,14 @@ import * as core from '@actions/core'
2
2
import { mkdirp } from './src/downloader'
3
3
import { restoreCache , saveCache } from '@actions/cache'
4
4
import process from 'process'
5
- import { spawnSync } from 'child_process'
6
- import { getViaGit } from './src/git'
5
+ import { spawn , spawnSync } from 'child_process'
6
+ import { getArtifactMetadata , getViaGit } from './src/git'
7
+ import * as fs from 'fs'
8
+
9
+ const flavor = core . getInput ( 'flavor' )
10
+ const architecture = core . getInput ( 'architecture' )
11
+ const architectureToDownload =
12
+ architecture === 'aarch64' ? 'x86_64' : architecture
7
13
8
14
async function run ( ) : Promise < void > {
9
15
try {
@@ -13,12 +19,14 @@ async function run(): Promise<void> {
13
19
)
14
20
return
15
21
}
16
- const flavor = core . getInput ( 'flavor' )
17
- const architecture = core . getInput ( 'architecture' )
22
+
18
23
const verbose = core . getInput ( 'verbose' )
19
24
const msysMode = core . getInput ( 'msys' ) === 'true'
20
25
21
- const { artifactName, download, id} = await getViaGit ( flavor , architecture )
26
+ const { artifactName, download, id} = await getViaGit (
27
+ flavor ,
28
+ architectureToDownload
29
+ )
22
30
const outputDirectory = core . getInput ( 'path' ) || `C:/${ artifactName } `
23
31
let useCache : boolean
24
32
switch ( core . getInput ( 'cache' ) ) {
@@ -61,7 +69,22 @@ async function run(): Promise<void> {
61
69
}
62
70
}
63
71
64
- const mingw = architecture === 'i686' ? 'MINGW32' : 'MINGW64'
72
+ let mingw = ''
73
+
74
+ switch ( architecture ) {
75
+ case 'i686' :
76
+ mingw = 'MINGW32'
77
+ break
78
+ case 'x86_64' :
79
+ mingw = 'MINGW64'
80
+ break
81
+ case 'aarch64' :
82
+ mingw = 'CLANGARM64'
83
+ break
84
+ default :
85
+ core . setFailed ( `Invalid architecture ${ architecture } specified` )
86
+ }
87
+
65
88
const msystem = msysMode ? 'MSYS' : mingw
66
89
67
90
const binPaths = [
@@ -109,9 +132,72 @@ async function run(): Promise<void> {
109
132
} ) ) {
110
133
ln ( `/dev/${ linkPath } ` , `/proc/self/${ target } ` )
111
134
}
135
+
136
+ if ( msystem === 'CLANGARM64' ) {
137
+ // ARM64 dependencies aren't included yet in the Git for Windows SDK. Ask Pacman to install them.
138
+ await installArm64Dependencies ( outputDirectory )
139
+ }
112
140
} catch ( error ) {
113
141
core . setFailed ( error instanceof Error ? error . message : `${ error } ` )
114
142
}
115
143
}
116
144
117
- run ( )
145
+ async function installArm64Dependencies (
146
+ outputDirectory : string
147
+ ) : Promise < void > {
148
+ core . info ( 'Installing CLANGARM64 dependencies...' )
149
+ mkdirp ( `${ outputDirectory } /clangarm64` )
150
+ fs . appendFileSync (
151
+ `${ outputDirectory } /etc/pacman.conf` ,
152
+ `
153
+ [clangarm64]
154
+ Server = https://mirror.msys2.org/mingw/clangarm64/`
155
+ )
156
+
157
+ const child = spawn ( 'pacman.exe' , [
158
+ '-Sy' ,
159
+ '--noconfirm' ,
160
+ 'base-devel' ,
161
+ 'mingw-w64-clang-aarch64-openssl' ,
162
+ 'mingw-w64-clang-aarch64-zlib' ,
163
+ 'mingw-w64-clang-aarch64-curl' ,
164
+ 'mingw-w64-clang-aarch64-expat' ,
165
+ 'mingw-w64-clang-aarch64-libiconv' ,
166
+ 'mingw-w64-clang-aarch64-toolchain' ,
167
+ 'mingw-w64-clang-aarch64-pcre2' ,
168
+ 'mingw-w64-clang-aarch64-libssp'
169
+ ] )
170
+
171
+ child . stdout . on ( 'data' , data => {
172
+ core . info ( data )
173
+ } )
174
+
175
+ child . stderr . on ( 'data' , data => {
176
+ core . error ( data )
177
+ } )
178
+
179
+ return new Promise ( ( resolve , reject ) => {
180
+ child . on ( 'error' , error => reject ( error ) )
181
+ child . on ( 'close' , status =>
182
+ status === 0
183
+ ? resolve ( )
184
+ : reject ( new Error ( `Process exited with status code ${ status } ` ) )
185
+ )
186
+ } )
187
+ }
188
+
189
+ function cleanup ( ) : void {
190
+ const { artifactName} = getArtifactMetadata ( flavor , architectureToDownload )
191
+ const outputDirectory = core . getInput ( 'path' ) || `C:/${ artifactName } `
192
+
193
+ core . info ( `Cleaning up ${ outputDirectory } ...` )
194
+ fs . rmSync ( outputDirectory , { recursive : true , force : true } )
195
+ core . info ( `Finished cleaning up ${ outputDirectory } .` )
196
+ }
197
+
198
+ // If the POST action is running, we cleanup our artifacts
199
+ if ( process . env [ 'STATE_isPost' ] ) {
200
+ cleanup ( )
201
+ } else {
202
+ run ( )
203
+ }
0 commit comments