Skip to content

Commit f62cd1e

Browse files
authored
Added some helper scripts (#260)
1 parent f3a08cd commit f62cd1e

File tree

4 files changed

+262
-15
lines changed

4 files changed

+262
-15
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ packages
3131
/out
3232
/CMakeUserPresets.json
3333
/build/vcpkg_installed
34+
/build/*.exe

CMakePresets.json

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{
22
"version": 3,
3+
"cmakeMinimumRequired": {
4+
"major": 3,
5+
"minor": 21
6+
},
37
"configurePresets": [
48
{
59
"name": "base",
@@ -10,14 +14,15 @@
1014
"binaryDir": "${sourceDir}/out/build/${presetName}",
1115
"installDir": "${sourceDir}/out/install/${presetName}"
1216
},
13-
1417
{
1518
"name": "x64",
1619
"architecture": {
1720
"value": "x64",
1821
"strategy": "external"
1922
},
20-
"cacheVariables": { "DIRECTX_ARCH": "x64" },
23+
"cacheVariables": {
24+
"DIRECTX_ARCH": "x64"
25+
},
2126
"hidden": true
2227
},
2328
{
@@ -26,7 +31,9 @@
2631
"value": "x86",
2732
"strategy": "external"
2833
},
29-
"cacheVariables": { "DIRECTX_ARCH": "x86" },
34+
"cacheVariables": {
35+
"DIRECTX_ARCH": "x86"
36+
},
3037
"hidden": true
3138
},
3239
{
@@ -35,7 +42,9 @@
3542
"value": "arm64",
3643
"strategy": "external"
3744
},
38-
"cacheVariables": { "DIRECTX_ARCH": "arm64" },
45+
"cacheVariables": {
46+
"DIRECTX_ARCH": "arm64"
47+
},
3948
"hidden": true
4049
},
4150
{
@@ -44,29 +53,30 @@
4453
"value": "arm64ec",
4554
"strategy": "external"
4655
},
47-
"cacheVariables": { "DIRECTX_ARCH": "arm64ec" },
56+
"cacheVariables": {
57+
"DIRECTX_ARCH": "arm64ec"
58+
},
4859
"environment": {
4960
"CFLAGS": "/arm64EC",
5061
"CXXFLAGS": "/arm64EC"
5162
},
5263
"hidden": true
5364
},
54-
5565
{
5666
"name": "Debug",
57-
"cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" },
67+
"cacheVariables": {
68+
"CMAKE_BUILD_TYPE": "Debug"
69+
},
5870
"hidden": true
5971
},
6072
{
6173
"name": "Release",
62-
"cacheVariables":
63-
{
64-
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
65-
"CMAKE_INTERPROCEDURAL_OPTIMIZATION": true
74+
"cacheVariables": {
75+
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
76+
"CMAKE_INTERPROCEDURAL_OPTIMIZATION": true
6677
},
6778
"hidden": true
6879
},
69-
7080
{
7181
"name": "UWP",
7282
"cacheVariables": {
@@ -97,12 +107,10 @@
97107
{
98108
"name": "Tools",
99109
"cacheVariables": {
100-
"BUILD_TOOLS" : true
110+
"BUILD_TOOLS": true
101111
},
102112
"hidden": true
103113
},
104-
105-
106114
{
107115
"name": "MSVC",
108116
"hidden": true,
@@ -274,6 +282,7 @@
274282

275283
{ "name": "x64-Analyze" , "description": "MSVC for x64 (Debug) using /analyze", "inherits": [ "base", "x64", "Debug", "VCPKG", "MSVC", "Tools" ], "cacheVariables": { "ENABLE_CODE_ANALYSIS": true } }
276284
],
285+
277286
"testPresets": [
278287
{ "name": "x64-Debug" , "configurePreset": "x64-Debug" },
279288
{ "name": "x64-Release" , "configurePreset": "x64-Release" },

build/downloadbuild.ps1

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<#
2+
3+
.NOTES
4+
Copyright (c) Microsoft Corporation.
5+
Licensed under the MIT License.
6+
7+
.SYNOPSIS
8+
Downloads build artifacts from Azure DevOps for UVAtlas.
9+
10+
.DESCRIPTION
11+
This script is used as part of the internal release process for UVAtlas.
12+
13+
.PARAMETER BuildId
14+
This is the specific build to get artifacts from.
15+
16+
.PARAMETER PAT
17+
Requires an ADO PAT with 'Build > Read' scope. Can be provided via the ADO_PERSONAL_ACCESS_TOKEN environment variable or as a parameter.
18+
19+
.LINK
20+
https://github.com/microsoft/UVAtlas/wiki
21+
22+
#>
23+
24+
param(
25+
[Parameter(Mandatory)]
26+
[int]$BuildId,
27+
[string]$PAT = ""
28+
)
29+
30+
# Parse PAT
31+
if ($PAT.Length -eq 0) {
32+
$PAT = $env:ADO_PERSONAL_ACCESS_TOKEN
33+
34+
if ($PAT.Length -eq 0) {
35+
Write-Error "##[error]This script requires a valid ADO Personal Access Token!" -ErrorAction Stop
36+
}
37+
}
38+
39+
# Initial REST query
40+
$headers = @{
41+
"Content-Type" = "application/json"
42+
Authorization = "Basic " + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$PAT"))
43+
}
44+
45+
$uriFormat = "https://dev.azure.com/MSCodeHub/c083e54b-cdc7-4b8b-8bf6-0d874500b610/_apis/build/builds/{0}/artifacts?artifactName={1}&api-version=7.1"
46+
47+
$uriamd64 = $uriFormat -f $BuildId, "UVAtlas_Binaries_Release_x64"
48+
49+
try
50+
{
51+
Write-Host "Checking if build and artifacts exist..."
52+
$responseamd64 = Invoke-RestMethod -Uri $uriamd64 -Method Get -Headers $headers
53+
}
54+
catch
55+
{
56+
Write-Error "##[error]Build $BuildId not found!" -ErrorAction Continue
57+
}
58+
59+
$ProgressPreference = 'SilentlyContinue'
60+
61+
$tempFolderPath = Join-Path $Env:Temp $(New-Guid)
62+
New-Item -Type Directory -Path $tempFolderPath | Out-Null
63+
64+
Write-Host $tempFolderPath
65+
66+
$headers = @{
67+
Authorization = "Basic " + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$PAT"))
68+
Accept = "application/zip"
69+
}
70+
71+
Add-Type -A System.IO.Compression.FileSystem
72+
73+
# Download artifacts for X64
74+
foreach ($artifact in $responseamd64) {
75+
$artifactName = $artifact.name
76+
$downloadUrl = $artifact.resource.downloadUrl
77+
$outputFile = Join-Path $tempFolderPath "$artifactName.zip"
78+
79+
try
80+
{
81+
Write-Host "Downloading $artifactName to $outputFile..."
82+
Invoke-WebRequest -Uri $downloadUrl -Headers $headers -OutFile $outputFile
83+
}
84+
catch
85+
{
86+
Write-Error "##[error]Failed to download $artifactName!" -ErrorAction Continue
87+
}
88+
89+
try
90+
{
91+
Write-Host "Extracting $artifactName..."
92+
[IO.Compression.ZipFile]::ExtractToDirectory($outputFile, $tempFolderPath)
93+
}
94+
catch
95+
{
96+
Write-Error "##[error]Failed to extract $artifactName!" -ErrorAction Continue
97+
}
98+
}
99+
100+
# Extract command-line tool binary
101+
$exe = "UVAtlasTool"
102+
103+
$binPath = Join-Path $tempFolderPath "UVAtlas_Binaries_Release_x64"
104+
$srcPath = "{0}\{1}\Bin\Desktop_2022\x64\Release\{1}.exe" -f $binPath, $exe
105+
Copy-Item -Path $srcPath -Destination "." -ErrorAction Stop

build/promotenuget.ps1

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
<#
2+
3+
.NOTES
4+
Copyright (c) Microsoft Corporation.
5+
Licensed under the MIT License.
6+
7+
.SYNOPSIS
8+
This promotes the NuGet packages on the project-scoped feed.
9+
10+
.DESCRIPTION
11+
This script promotes the views of the UVAtlas NuGet packages on the project-scoped feed. It always promotes to Prerelease view, and if the Release switch is set, it also promotes to Release view.
12+
13+
.PARAMETER Version
14+
Indicates which version of the packages to promote.
15+
16+
.PARAMETER PAT
17+
Requires an ADO PAT with 'Packaging > Read, write, and manage' scope. Can be provided via the ADO_PERSONAL_ACCESS_TOKEN environment variable or as a parameter.
18+
19+
.PARAMETER Release
20+
By default promotes to prerelease. If this switch is set, promotes to release as well.
21+
22+
.LINK
23+
https://github.com/microsoft/UVAtlas/wiki
24+
25+
#>
26+
27+
param(
28+
[Parameter(Mandatory)]
29+
[string]$Version,
30+
[string]$PAT = "",
31+
[switch]$Release
32+
)
33+
34+
# Parse PAT
35+
if ($PAT.Length -eq 0) {
36+
$PAT = $env:ADO_PERSONAL_ACCESS_TOKEN
37+
38+
if ($PAT.Length -eq 0) {
39+
Write-Error "##[error]This script requires a valid ADO Personal Access Token!" -ErrorAction Stop
40+
}
41+
}
42+
43+
# Project-scoped feed root (package name and version to be filled in later)
44+
$uriFormat = "https://pkgs.dev.azure.com/MSCodeHub/c083e54b-cdc7-4b8b-8bf6-0d874500b610/_apis/packaging/feeds/f34c46a0-2801-4711-aa81-2c6961a441d4/nuget/packages/{0}/versions/{1}?api-version=7.1"
45+
46+
$headers = @{
47+
"Content-Type" = "application/json"
48+
Authorization = "Basic " + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$PAT"))
49+
}
50+
51+
$bodyPrerelease = @{
52+
views = @{
53+
op = "add"
54+
path = "/views/-"
55+
value = "Prerelease"
56+
}
57+
} | ConvertTo-Json
58+
59+
$bodyRelease = @{
60+
views = @{
61+
op = "add"
62+
path = "/views/-"
63+
value = "Release"
64+
}
65+
} | ConvertTo-Json
66+
67+
$packages = @('uvatlas_desktop_2019', 'uvatlas_desktop_win10')
68+
69+
# Check if all packages exist
70+
$allPackagesSucceeded = $true
71+
foreach ($package in $packages) {
72+
$uri = $uriFormat -f $package, $Version
73+
74+
try
75+
{
76+
Write-Host "Checking if $package version $Version exists..."
77+
Invoke-RestMethod -Uri $uri -Method Get -Headers $headers
78+
}
79+
catch
80+
{
81+
Write-Error "##[error]Package $package version $Version not found!" -ErrorAction Continue
82+
$allPackagesSucceeded = $false
83+
}
84+
}
85+
86+
if (-not $allPackagesSucceeded) {
87+
Write-Error "##[error]Not all packages found. Aborting promotion." -ErrorAction Stop
88+
}
89+
90+
# Promote package to Prerelease view
91+
foreach ($package in $packages) {
92+
$uri = $uriFormat -f $package, $Version
93+
94+
try
95+
{
96+
# Promote to Prerelease view
97+
Write-Host "Promoting $package version $Version to Prerelease view..."
98+
Invoke-RestMethod -Uri $uri -Method Patch -Headers $headers -Body $bodyPrerelease
99+
}
100+
catch
101+
{
102+
Write-Error "##[error]Package $package version $Version failed to promote" -ErrorAction Continue
103+
$allPackagesSucceeded = $false
104+
}
105+
}
106+
107+
if (-not $allPackagesSucceeded) {
108+
Write-Error "##[error]Not all packages promoted to Prerelease." -ErrorAction Stop
109+
}
110+
111+
# Optionally promote package to Release view
112+
if ($Release.IsPresent) {
113+
foreach ($package in $packages) {
114+
$uri = $uriFormat -f $package, $Version
115+
116+
try
117+
{
118+
# Promote to Release view
119+
Write-Host "Promoting $package version $Version to Release view..."
120+
Invoke-RestMethod -Uri $uri -Method Patch -Headers $headers -Body $bodyRelease
121+
}
122+
catch
123+
{
124+
Write-Error "##[error]Package $package version $Version failed to promote" -ErrorAction Continue
125+
$allPackagesSucceeded = $false
126+
}
127+
}
128+
129+
if (-not $allPackagesSucceeded) {
130+
Write-Error "##[error]Not all packages promoted to Release." -ErrorAction Stop
131+
}
132+
}

0 commit comments

Comments
 (0)