azure-sdk-for-cpp/eng/scripts/Test-ShouldReleaseToVcpkg.ps1
Daniel Jurek a91d151e79
Vcpkg Beta Automation (for real) (#3497)
* Script that automates updating vcpkg betas

* Wire up to pipeline

* Spelling, commentary

* Clone into repo name

* Remove-Item requires the path to exist, even if -Force is specified

* Bootstrap vcpkg

* Arguments to Test-ShouldReleaseToVcpkg.ps1

* More commit

* Escape quotes

* Quote git commit

* Set strict mode

* Use tags

* Actually tag

* Run git commands

* Invoke-Expression

* Onboard releasing package to vcpkg before attempting to isntall from overaly

* temporarily disable matrix generation (30s tasks sometimes runs for 20+ minutes)

* Test-ShouldReleaseToVcpkg.ps1

* Test-Path

* Test vcpkg build, also ensure we push

* Just the tags... low probabiltiy of success given that '--' if frequently treated as a separator

* Add ability to skip link verification for tighter inner loop

* Push tag separately

* Unnecessary condition and conjunction

* Base repo owner: Azure

* Specify remote name

* Tighten inner loop

* git remote -v

* workingDirectory

* Go back to two tags and a regular push

* Saving some progress

* Use original push method

* BaseRepoOwner

* Cleanup, put changes in the default branch (vcpkg does not look at refs outside of the default branch)

* Use default branch

* Revert changes used to tighten up devops inner loop

* Revert an unrelated change

* Revert unrelated changes

* Revert unrelated changes

* Add spelling
2022-04-01 06:30:03 -07:00

47 lines
1.7 KiB
PowerShell

param(
[string] $ReleaseArtifactSourceDirectory,
[string] $VcpkgFolder,
[string] $VcpkgPortName
)
."$PSSCriptRoot/../common/scripts/common.ps1"
Set-StrictMode -Version 3
$packageJsonContents = Get-Content `
-Path "$ReleaseArtifactSourceDirectory/package-info.json" `
-Raw
$packageJson = ConvertFrom-Json $packageJsonContents
$packageVersionSemver = [AzureEngSemanticVersion]::ParseVersionString($packageJson.version)
if (!$packageVersionSemver.IsPrerelease) {
Write-Host "Package version is GA ($($packageJson.version)), publish to vcpkg"
Write-Host "##vso[task.setvariable variable=PublishToVcpkg]true"
exit 0
}
Write-Host "Released package is preview"
# The package does not exist in vcpkg, publish to vcpkg
$vcpkgJsonPath = "$VcpkgFolder/ports/$VcpkgPortName/vcpkg.json"
if (!(Test-Path $vcpkgJsonPath)) {
Write-Host "Package ($VcpkgPortName) has not been published, publish to vcpkg"
Write-Host "##vso[task.setvariable variable=PublishToVcpkg]true"
exit 0
}
Write-Host "Package has been published before"
$vcpkgJsonContents = Get-Content -Raw -Path $vcpkgJsonPath
$vcpkgJson = ConvertFrom-Json $vcpkgJsonContents
$existingVersion = [AzureEngSemanticVersion]::ParseVersionString($vcpkgJson.'version-semver')
# Published version is a prerelease
if ($existingVersion.IsPrerelease) {
Write-Host "Existing version ($($vcpkgJson.'version-semver')) is prerelease, publish to vcpkg"
Write-Host "##vso[task.setvariable variable=PublishToVcpkg]true"
exit 0
}
Write-Host "Existing version is GA"
Write-Host "Criteria for publishing not satisifed, do NOT publish to vcpkg"
Write-Host "##vso[task.setvariable variable=PublishToVcpkg]false"