Skip to content

Commit 398bf88

Browse files
committed
Add input in php workflow to not upload the builds
1 parent 3ee2b6e commit 398bf88

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed

.github/workflows/php.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ on:
66
php-version:
77
description: 'PHP version to build'
88
required: true
9+
upload:
10+
type: choice
11+
options: ['true', 'false']
12+
description: Upload artifacts to the downloads server
13+
required: false
14+
default: 'true'
915

1016
jobs:
1117
php:
@@ -40,6 +46,7 @@ jobs:
4046
upload:
4147
runs-on: ubuntu-latest
4248
needs: artifacts
49+
if: ${{ github.event.inputs.upload == 'true' }}
4350
steps:
4451
- name: Upload to downloads server
4552
run: |

php/BuildPhp/private/Add-VS.ps1

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
function Add-Vs {
2+
<#
3+
.SYNOPSIS
4+
Add the required Visual Studio components.
5+
.PARAMETER VsConfig
6+
Visual Studio Configuration
7+
.PARAMETER VsVersion
8+
Visual Studio Version
9+
#>
10+
[OutputType()]
11+
param (
12+
[Parameter(Mandatory = $true, Position=0, HelpMessage='Visual Studio Version')]
13+
[ValidateNotNull()]
14+
[ValidateLength(1, [int]::MaxValue)]
15+
[string] $VsVersion,
16+
[Parameter(Mandatory = $true, Position=1, HelpMessage='Visual Studio Configuration')]
17+
[PSCustomObject] $VsConfig
18+
)
19+
begin {
20+
$vsWhereUrl = 'https://github.com/microsoft/vswhere/releases/latest/download/vswhere.exe'
21+
}
22+
process {
23+
$Config = $VsConfig.vs.$VsVersion
24+
25+
$installerDir = Join-Path "${env:ProgramFiles(x86)}\Microsoft Visual Studio" 'Installer'
26+
$vswherePath = Join-Path $installerDir 'vswhere.exe'
27+
if (-not (Test-Path $vswherePath)) {
28+
if (-not (Test-Path $installerDir)) {
29+
New-Item -Path $installerDir -ItemType Directory -Force | Out-Null
30+
}
31+
Invoke-WebRequest -Uri $vsWhereUrl -OutFile $vswherePath -UseBasicParsing
32+
}
33+
34+
$instances = & $vswherePath -products '*' -format json 2> $null | ConvertFrom-Json
35+
$vsInst = $instances | Select-Object -First 1
36+
37+
$componentArgs = $Config.components | ForEach-Object { '--add'; $_ }
38+
39+
if ($vsInst) {
40+
[string]$channel = $vsInst.installationVersion.Split('.')[0]
41+
if ($vsInst.catalog.productId -match '(Enterprise|Professional|Community)$' ) {
42+
$exe = "vs_$($Matches[1].ToLower()).exe"
43+
} else {
44+
$exe = 'vs_buildtools.exe'
45+
}
46+
47+
$installerUrl = "https://aka.ms/vs/$channel/release/$exe"
48+
$installerPath = Join-Path $env:TEMP $exe
49+
50+
Invoke-WebRequest -Uri $installerUrl -OutFile $installerPath -UseBasicParsing
51+
52+
& $installerPath modify `
53+
--installPath $vsInst.installationPath `
54+
--quiet --wait --norestart --nocache `
55+
@componentArgs 2>&1 | ForEach-Object { Write-Host $_ }
56+
} else {
57+
$channel = $VsVersion -replace '\D', ''
58+
$exe = 'vs_buildtools.exe'
59+
$installerUrl = "https://aka.ms/vs/$channel/release/$exe"
60+
$installerPath = Join-Path $env:TEMP $exe
61+
62+
Invoke-WebRequest -Uri $installerUrl -OutFile $installerPath -UseBasicParsing
63+
& $installerPath `
64+
--quiet --wait --norestart --nocache `
65+
@componentArgs 2>&1 | ForEach-Object { Write-Host $_ }
66+
}
67+
}
68+
end {
69+
}
70+
}

0 commit comments

Comments
 (0)