-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaction.yml
87 lines (80 loc) · 3.3 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: Install llvm-msvc
description: Install llvm-msvc
inputs:
version:
description: Version to install
required: false
default: latest
path:
description: Path to store installer
required: false
default: $env:TEMP
token:
description: The GitHub token used to create an authenticated client
default: ${{ github.token }}
required: false
runs:
using: composite
steps:
- name: Run as admin
run: |
$psCommand = 'Start-Process ' + "`"${env:GITHUB_ACTION}`"" + ' -Verb RunAs'
Start-Process powershell -Verb RunAs -ArgumentList 'Invoke-Expression', $psCommand
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
shell: powershell
- name: Get the latest release of llvm-msvc
id: llvm-msvc-latest_release
uses: actions/github-script@v6
with:
github-token: ${{ inputs.token }}
script: |
const { data } = await github.request('GET /repos/{owner}/{repo}/releases/latest', {
owner: 'backengineering',
repo: 'llvm-msvc'
})
console.log(data.tag_name)
return data.tag_name
- name: Download and Install llvm-msvc_X86_64_installer.exe
run: |
Write-Host "Checking if llvm-msvc_X86_64_installer.exe already exists."
$releaseVersion = "${{ inputs.version }}"
Write-Host "Version: $releaseVersion"
if ($releaseVersion -eq "latest") {
Write-Host "Use the latest version."
$releaseVersion = ${{ steps.llvm-msvc-latest_release.outputs.result }}
}
$releaseFolder = "${{ inputs.path }}\$releaseVersion"
Write-Host "Release folder: $releaseFolder"
if (!(Test-Path -Path $releaseFolder)) {
New-Item -ItemType Directory -Force -Path $releaseFolder
}
$exe = Join-Path $releaseFolder 'llvm-msvc_X86_64_installer.exe'
Write-Host "exe: $exe"
if (!(Test-Path -Path $exe)) {
Write-Host "Downloading llvm-msvc_X86_64_installer.exe..."
$owner = "backengineering"
$repo = "llvm-msvc"
$tag = $releaseVersion
$file = "llvm-msvc_X86_64_installer.exe"
$credentials="${{ inputs.token }}"
$releasesUrl = "https://api.github.com/repos/$owner/$repo/releases/tags/$tag"
$headers = @{
"Accept" = "application/vnd.github.v3+json"
"Authorization" = "token $credentials"
}
$releases = Invoke-WebRequest -Uri $releasesUrl -Headers $headers | ConvertFrom-Json
$assetId = ($releases.assets | Where-Object { $_.name -eq $file }).id
Write-Host "Asset ID: $assetId"
$url = "https://" + $credentials + ":@api.github.com/repos/$owner/$repo/releases/assets/$assetId"
$headers2 = @{
"Accept" = "application/octet-stream"
"Authorization" = "token $credentials"
}
Invoke-WebRequest -Uri $url -Headers $headers2 -OutFile $exe
} else {
Write-Host "llvm-msvc_X86_64_installer.exe already exists."
}
Write-Host "Installing llvm-msvc_X86_64_installer.exe..."
Start-Process -Wait -FilePath $exe -ArgumentList '/verysilent' -Verb RunAs
Write-Host "llvm-msvc_X86_64_installer.exe installed successfully."
shell: powershell