2024-02-28 15:41:50 +03:00
|
|
|
# This Yaml Document has been converted by ESAI Yaml Pipeline Conversion Tool.
|
2024-07-12 16:19:38 +03:00
|
|
|
trigger:
|
2024-07-29 12:32:06 +03:00
|
|
|
branches:
|
|
|
|
include:
|
|
|
|
- '*'
|
|
|
|
paths:
|
|
|
|
include:
|
|
|
|
- release
|
|
|
|
- .azure-pipelines
|
|
|
|
- .vsts.release.yml
|
|
|
|
|
|
|
|
pr:
|
|
|
|
branches:
|
|
|
|
include:
|
|
|
|
- '*'
|
2024-07-12 16:19:38 +03:00
|
|
|
paths:
|
|
|
|
include:
|
|
|
|
- release
|
|
|
|
- .azure-pipelines
|
|
|
|
- .vsts.release.yml
|
|
|
|
|
2023-11-08 13:09:33 +03:00
|
|
|
schedules:
|
|
|
|
- cron: '0 6 * * 2'
|
|
|
|
displayName: Scheduled weekly run
|
|
|
|
branches:
|
|
|
|
include:
|
|
|
|
- master
|
|
|
|
|
2020-04-08 20:42:44 +03:00
|
|
|
parameters:
|
|
|
|
- name: version
|
|
|
|
type: string
|
|
|
|
displayName: Version
|
2023-11-08 13:09:33 +03:00
|
|
|
default: 'NotSet'
|
2024-09-09 16:12:22 +03:00
|
|
|
- name: targetFramework
|
|
|
|
displayName: Target framework
|
|
|
|
type: string
|
|
|
|
default: net6.0
|
|
|
|
values:
|
|
|
|
- net6.0
|
|
|
|
- net8.0
|
2020-04-08 20:42:44 +03:00
|
|
|
- name: derivedFrom
|
|
|
|
type: string
|
|
|
|
displayName: Derived From Version
|
|
|
|
default: latest
|
2020-04-29 21:09:32 +03:00
|
|
|
- name: skipTests
|
|
|
|
type: boolean
|
|
|
|
default: false
|
|
|
|
displayName: Skip Tests
|
2020-08-20 23:13:39 +03:00
|
|
|
# buildStageOnly is useful for testing changes of the build stage which cannot be tested
|
|
|
|
# in the ci project, like signing, without actually doing a release
|
|
|
|
- name: buildStageOnly
|
|
|
|
type: boolean
|
|
|
|
default: false
|
|
|
|
displayName: Build Stage Only
|
2020-04-08 20:42:44 +03:00
|
|
|
|
2022-10-17 21:59:18 +03:00
|
|
|
- name: onlyGitHubRelease
|
|
|
|
type: boolean
|
|
|
|
default: false
|
|
|
|
displayName: Release only for GitHub
|
|
|
|
|
2023-06-28 19:04:23 +03:00
|
|
|
- name: testProxyAgent
|
|
|
|
type: boolean
|
|
|
|
default: true
|
|
|
|
displayName: Test Proxy Agent
|
|
|
|
|
2024-02-28 15:41:50 +03:00
|
|
|
- name: disableNotifications
|
|
|
|
type: boolean
|
|
|
|
default: false
|
|
|
|
displayName: Disable Teams Notifications
|
|
|
|
|
|
|
|
# Skip CG
|
|
|
|
variables:
|
|
|
|
- name: OneES_JobScannedCount
|
|
|
|
value: 1
|
|
|
|
|
2020-04-08 20:42:44 +03:00
|
|
|
extends:
|
2024-02-28 15:41:50 +03:00
|
|
|
template: /.azure-pipelines/pipeline.yml@self
|
2020-04-08 20:42:44 +03:00
|
|
|
parameters:
|
2024-02-28 15:41:50 +03:00
|
|
|
branch: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.releaseBranch'] ]
|
2020-04-29 21:09:32 +03:00
|
|
|
test: ${{ not(parameters.skipTests) }}
|
2020-04-08 20:42:44 +03:00
|
|
|
sign: true
|
|
|
|
publishArtifacts: true
|
2024-09-09 16:12:22 +03:00
|
|
|
targetFramework: ${{ parameters.targetFramework }}
|
2023-06-28 19:04:23 +03:00
|
|
|
testProxyAgent: ${{ parameters.testProxyAgent }}
|
2023-11-08 13:09:33 +03:00
|
|
|
stageDependencies:
|
|
|
|
- Verify_release
|
|
|
|
- Create_Release_Branch
|
|
|
|
stageCondition: |
|
|
|
|
and(
|
|
|
|
succeeded('Verify_release'),
|
|
|
|
in(dependencies.Create_Release_Branch.result, 'Succeeded', 'Skipped')
|
|
|
|
)
|
2020-04-08 20:42:44 +03:00
|
|
|
|
2022-11-03 15:55:03 +03:00
|
|
|
preBuildStages:
|
2023-11-08 13:09:33 +03:00
|
|
|
- stage: Verify_release
|
|
|
|
displayName: Verify it's a release run
|
|
|
|
pool:
|
2024-02-28 15:41:50 +03:00
|
|
|
name: 1ES-ABTT-Shared-Pool
|
|
|
|
image: abtt-ubuntu-2204
|
|
|
|
os: linux
|
2023-11-08 13:09:33 +03:00
|
|
|
jobs:
|
|
|
|
- job: Set_variables
|
|
|
|
displayName: Set release-specific variables
|
|
|
|
steps:
|
|
|
|
- pwsh: |
|
|
|
|
$isBuildStageOnly = [System.Convert]::ToBoolean('${{ parameters.buildStageOnly }}')
|
|
|
|
$buildReason = '$(Build.Reason)'
|
|
|
|
|
|
|
|
$currentSprint = (Invoke-WebRequest https://whatsprintis.it -Headers @{"Accept" = "application/json" } | ConvertFrom-Json)
|
|
|
|
|
|
|
|
$isReleaseWeek = $currentSprint.week -eq 3
|
|
|
|
Write-Host "isReleaseWeek = $isReleaseWeek"
|
|
|
|
|
|
|
|
$isRelease = ($buildReason -eq 'Manual' -and !$isBuildStageOnly) -or ($buildReason -eq 'Schedule' -and $isReleaseWeek)
|
|
|
|
Write-Host "isRelease = $isRelease"
|
|
|
|
Write-Host "##vso[task.setVariable variable=isRelease;isOutput=true]$isRelease"
|
|
|
|
|
2024-07-12 16:19:38 +03:00
|
|
|
$isTestRun = ($buildReason -eq 'IndividualCI' -or $buildReason -eq 'PullRequest')
|
|
|
|
Write-Host "isTestRun = $isTestRun"
|
|
|
|
Write-Host "##vso[task.setVariable variable=isTestRun;isOutput=true]$isTestRun"
|
|
|
|
|
2023-11-08 13:09:33 +03:00
|
|
|
$isScheduledRelease = $isRelease -and $buildReason -eq 'Schedule'
|
|
|
|
Write-Host "isScheduledRelease = $isScheduledRelease"
|
|
|
|
|
2024-07-12 16:19:38 +03:00
|
|
|
if ($isRelease -or $isTestRun) {
|
|
|
|
if ($isScheduledRelease -or $isTestRun) {
|
2023-12-14 19:01:48 +03:00
|
|
|
$majorAndMinorVersion = "3.$($currentSprint.sprint)"
|
|
|
|
$patchVersion = 0
|
|
|
|
## Looking for a free patch version
|
|
|
|
while ($true) {
|
|
|
|
$agentVersion = "$majorAndMinorVersion.$patchVersion"
|
|
|
|
git ls-remote --exit-code --heads origin refs/heads/releases/$agentVersion
|
|
|
|
if ($LASTEXITCODE -ne 0) {
|
|
|
|
if ($LASTEXITCODE -eq 2) {
|
|
|
|
$LASTEXITCODE = 0
|
|
|
|
break
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Write-Error "git ls-remote failed with exit code $LASTEXITCODE" -ErrorAction Stop
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$patchVersion++
|
|
|
|
}
|
2023-11-08 13:09:33 +03:00
|
|
|
} else {
|
|
|
|
$agentVersion = "${{ parameters.version }}"
|
|
|
|
if ($agentVersion -eq 'NotSet') {
|
|
|
|
Write-Error "Version parameter is required for manual release." -ErrorAction Stop
|
|
|
|
}
|
2024-09-09 16:12:22 +03:00
|
|
|
|
|
|
|
## Verify target framework for specified version
|
|
|
|
$majorVersion = $agentVersion.Split('.')[0]
|
2024-09-09 17:49:41 +03:00
|
|
|
if (("${{ parameters.targetFramework }}" -eq "net6.0" -and $majorVersion -ne "3") -or
|
|
|
|
("${{ parameters.targetFramework }}" -eq "net8.0" -and $majorVersion -ne "4")) {
|
2024-09-09 16:12:22 +03:00
|
|
|
Write-Error "The major version should be 3 for net6.0 and 4 for net8.0" -ErrorAction Stop
|
|
|
|
}
|
2023-11-08 13:09:33 +03:00
|
|
|
}
|
2024-07-12 16:19:38 +03:00
|
|
|
if ($isTestRun) {
|
|
|
|
$agentVersion = '3.000.999'
|
|
|
|
}
|
2023-11-08 13:09:33 +03:00
|
|
|
Write-Host "agentVersion = $agentVersion"
|
|
|
|
Write-Host "##vso[task.setVariable variable=agentVersion;isOutput=true]$agentVersion"
|
|
|
|
|
|
|
|
$releaseBranch = "releases/$agentVersion"
|
|
|
|
Write-Host "releaseBranch = $releaseBranch"
|
|
|
|
Write-Host "##vso[task.setVariable variable=releaseBranch;isOutput=true]$releaseBranch"
|
|
|
|
}
|
|
|
|
|
|
|
|
name: SetReleaseVariables
|
|
|
|
displayName: Set release-specific variables
|
|
|
|
|
|
|
|
- stage: Create_Release_Branch
|
|
|
|
displayName: Create Release Branch
|
|
|
|
dependsOn:
|
|
|
|
- Verify_release
|
|
|
|
jobs:
|
|
|
|
################################################################################
|
|
|
|
- job: Create_Release_Branch
|
|
|
|
################################################################################
|
2022-11-03 15:55:03 +03:00
|
|
|
displayName: Create Release Branch
|
2023-11-08 13:09:33 +03:00
|
|
|
variables:
|
2024-07-12 16:19:38 +03:00
|
|
|
IsTestRun: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.isTestRun'] ]
|
2023-11-08 13:09:33 +03:00
|
|
|
IsRelease: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.isRelease'] ]
|
|
|
|
ReleaseBranch: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.releaseBranch'] ]
|
|
|
|
AgentVersion: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.agentVersion'] ]
|
2024-07-12 16:19:38 +03:00
|
|
|
condition: and(succeeded(), or(eq(variables.IsRelease, 'True'), eq(variables.IsTestRun, 'True')))
|
|
|
|
|
2023-11-08 13:09:33 +03:00
|
|
|
pool:
|
2024-02-28 15:41:50 +03:00
|
|
|
name: 1ES-ABTT-Shared-Pool
|
|
|
|
image: abtt-ubuntu-2204
|
|
|
|
os: linux
|
2023-11-08 13:09:33 +03:00
|
|
|
steps:
|
2020-08-20 23:13:39 +03:00
|
|
|
|
2023-11-08 13:09:33 +03:00
|
|
|
- checkout: self
|
2021-09-02 11:48:55 +03:00
|
|
|
|
2023-11-08 13:09:33 +03:00
|
|
|
- task: NodeTool@0
|
|
|
|
displayName: Use node 14.15.1
|
|
|
|
inputs:
|
|
|
|
versionSpec: "14.15.1"
|
2020-08-20 23:13:39 +03:00
|
|
|
|
2023-11-08 13:09:33 +03:00
|
|
|
- script: |
|
|
|
|
cd release
|
|
|
|
npm install
|
|
|
|
|
|
|
|
node createReleaseBranch.js $(AgentVersion) --derivedFrom=${{ parameters.derivedFrom }}
|
|
|
|
env:
|
|
|
|
EDITOR: cat
|
|
|
|
PAT: $(GithubToken)
|
|
|
|
displayName: Push release branch to GitHub
|
2020-08-20 23:13:39 +03:00
|
|
|
|
2022-11-03 15:55:03 +03:00
|
|
|
postBuildStages:
|
2020-08-20 23:13:39 +03:00
|
|
|
- stage: Release
|
2023-11-08 13:09:33 +03:00
|
|
|
dependsOn:
|
|
|
|
- build
|
|
|
|
- Verify_release
|
2020-04-08 20:42:44 +03:00
|
|
|
jobs:
|
|
|
|
################################################################################
|
2020-08-20 23:13:39 +03:00
|
|
|
- job: publish_agent_packages
|
2020-04-08 20:42:44 +03:00
|
|
|
################################################################################
|
2020-08-20 23:13:39 +03:00
|
|
|
displayName: Publish Agents (Windows/Linux/OSX)
|
2020-04-08 20:42:44 +03:00
|
|
|
pool:
|
2024-02-26 12:54:25 +03:00
|
|
|
name: 1ES-Shared-Hosted-Pool_Windows-Server-2022
|
|
|
|
demands: AzurePS
|
2023-11-08 13:09:33 +03:00
|
|
|
variables:
|
2024-07-12 16:19:38 +03:00
|
|
|
IsTestRun: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.isTestRun'] ]
|
2023-11-08 13:09:33 +03:00
|
|
|
IsRelease: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.isRelease'] ]
|
|
|
|
ReleaseBranch: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.releaseBranch'] ]
|
|
|
|
AgentVersion: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.agentVersion'] ]
|
2024-07-12 16:19:38 +03:00
|
|
|
condition: and(succeeded(), or(eq(variables.IsRelease, 'True'), eq(variables.IsTestRun, 'True')))
|
2020-04-08 20:42:44 +03:00
|
|
|
steps:
|
|
|
|
|
2020-08-20 23:13:39 +03:00
|
|
|
# Clean
|
|
|
|
- checkout: self
|
|
|
|
clean: true
|
2020-04-08 20:42:44 +03:00
|
|
|
|
2024-02-07 21:51:32 +03:00
|
|
|
- task: PowerShell@2
|
2024-02-07 11:56:58 +03:00
|
|
|
displayName: Switch to release branch
|
2024-02-06 19:08:05 +03:00
|
|
|
inputs:
|
2024-02-07 21:51:32 +03:00
|
|
|
filePath: .azure-pipelines/scripts/switch-branch.ps1
|
2024-02-06 19:08:05 +03:00
|
|
|
env:
|
|
|
|
TARGET_BRANCH: $(ReleaseBranch)
|
2021-09-02 11:48:55 +03:00
|
|
|
|
2020-08-20 23:13:39 +03:00
|
|
|
# Download all agent packages from all previous phases
|
|
|
|
- task: DownloadBuildArtifacts@0
|
|
|
|
displayName: Download Agent Packages
|
|
|
|
inputs:
|
|
|
|
artifactName: agent
|
2020-04-08 20:42:44 +03:00
|
|
|
|
2022-11-04 15:59:45 +03:00
|
|
|
# Upload agent packages to Azure blob storage and refresh Azure CDN
|
2024-02-26 12:54:25 +03:00
|
|
|
- task: AzurePowerShell@5
|
2022-11-04 15:59:45 +03:00
|
|
|
displayName: Upload to Azure Blob
|
2024-02-26 12:54:25 +03:00
|
|
|
inputs:
|
2024-09-03 14:43:34 +03:00
|
|
|
pwsh: true
|
2024-02-26 12:54:25 +03:00
|
|
|
azurePowerShellVersion: 'LatestVersion'
|
2024-05-27 16:59:12 +03:00
|
|
|
azureSubscription: 'azure-pipelines-agent-vstsagentpackage-oauth'
|
2024-02-26 12:54:25 +03:00
|
|
|
scriptType: 'InlineScript'
|
|
|
|
inline: |
|
|
|
|
Write-Host "Preloading Azure modules." # This is for better performance, to avoid module-autoloading.
|
|
|
|
Import-Module Azure, Az.Accounts, Az.Storage, Az.Cdn -ErrorAction Ignore -PassThru
|
|
|
|
$uploadFiles = New-Object System.Collections.ArrayList
|
|
|
|
Select-AzSubscription -SubscriptionId $(SubscriptionId)
|
2024-05-27 16:59:12 +03:00
|
|
|
$storageContext = New-AzStorageContext -StorageAccountName vstsagentpackage -UseConnectedAccount
|
2024-02-26 12:54:25 +03:00
|
|
|
$versionDir = "$(AgentVersion)"
|
2024-07-12 16:19:38 +03:00
|
|
|
|
|
|
|
$container = "agent"
|
|
|
|
$isTestContainer = "$(IsTestRun)"
|
|
|
|
Write-Host "isTestContainer = $isTestContainer"
|
|
|
|
|
|
|
|
if ($isTestContainer -eq "True") {
|
|
|
|
$container = "testagent"
|
|
|
|
New-AzStorageContainer -Context $storageContext -Name $container -Permission Off
|
|
|
|
}
|
|
|
|
Write-Host "container = $container"
|
|
|
|
|
2024-02-26 12:54:25 +03:00
|
|
|
Get-ChildItem -LiteralPath "$(System.ArtifactsDirectory)/agent" | ForEach-Object {
|
|
|
|
$target=$_
|
2024-09-04 11:50:13 +03:00
|
|
|
$fullPath = $target.FullName
|
|
|
|
Get-ChildItem -LiteralPath "$fullPath" -Include "*.zip","*.tar.gz" | ForEach-Object {
|
2024-02-26 12:54:25 +03:00
|
|
|
$executable = $_
|
2024-09-04 11:50:13 +03:00
|
|
|
$execFullPath = $executable.FullName
|
|
|
|
$execName = $executable.Name
|
|
|
|
Write-Host "Uploading $execName to BlobStorage vstsagentpackage/$container/$versionDir"
|
|
|
|
Set-AzStorageBlobContent -Context $storageContext -Container $container -File "$execFullPath" -Blob "$versionDir/$execName" -Force
|
|
|
|
$uploadFiles.Add("/$container/$versionDir/$execName")
|
2024-02-26 12:54:25 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Write-Host "Purge Azure CDN Cache"
|
|
|
|
Clear-AzCdnEndpointContent -EndpointName vstsagentpackage -ProfileName vstsagentpackage -ResourceGroupName vstsagentpackage -ContentPath $uploadFiles
|
|
|
|
Write-Host "Force Refresh Azure CDN Cache"
|
|
|
|
Import-AzCdnEndpointContent -EndpointName vstsagentpackage -ProfileName vstsagentpackage -ResourceGroupName vstsagentpackage -ContentPath $uploadFiles
|
2020-04-08 20:42:44 +03:00
|
|
|
|
2024-07-12 16:19:38 +03:00
|
|
|
# Clean up blob container with test agent version
|
|
|
|
- task: AzurePowerShell@5
|
|
|
|
displayName: Delete Azure Blob container with test agent version
|
|
|
|
condition: and(succeeded(), eq(variables.IsTestRun, 'True'))
|
|
|
|
inputs:
|
2024-09-03 18:08:46 +03:00
|
|
|
pwsh: true
|
2024-07-12 16:19:38 +03:00
|
|
|
azurePowerShellVersion: 'LatestVersion'
|
|
|
|
azureSubscription: 'azure-pipelines-agent-vstsagentpackage-oauth'
|
|
|
|
scriptType: 'InlineScript'
|
|
|
|
inline: |
|
|
|
|
Import-Module Azure, Az.Accounts, Az.Storage -ErrorAction Ignore -PassThru
|
|
|
|
Select-AzSubscription -SubscriptionId $(SubscriptionId)
|
|
|
|
$storageContext = New-AzStorageContext -StorageAccountName vstsagentpackage -UseConnectedAccount
|
|
|
|
$container = 'testagent'
|
|
|
|
Remove-AzStorageContainer -Name $container -Context $storageContext -Force
|
|
|
|
|
2021-09-02 11:48:55 +03:00
|
|
|
# Download all agent hashes created in previous phases
|
|
|
|
- task: DownloadBuildArtifacts@0
|
|
|
|
displayName: Download Agent Hashes
|
|
|
|
inputs:
|
|
|
|
artifactName: hash
|
|
|
|
downloadPath: $(Build.SourcesDirectory)/_hashes
|
|
|
|
|
|
|
|
# Fill release notes with agent version and package hashes
|
|
|
|
- script: |
|
|
|
|
cd release
|
2023-11-08 13:09:33 +03:00
|
|
|
node fillReleaseNotesTemplate.js $(AgentVersion)
|
2021-09-02 11:48:55 +03:00
|
|
|
displayName: Fill release notes
|
|
|
|
|
2020-08-20 23:13:39 +03:00
|
|
|
# Create agent release on Github
|
|
|
|
- powershell: |
|
|
|
|
Write-Host "Creating github release."
|
2021-09-02 11:48:55 +03:00
|
|
|
$releaseNotes = [System.IO.File]::ReadAllText("$(Build.SourcesDirectory)\releaseNote.md")
|
2020-08-20 23:13:39 +03:00
|
|
|
$releaseData = @{
|
2023-11-08 13:09:33 +03:00
|
|
|
tag_name = "v$(AgentVersion)";
|
2020-08-20 23:13:39 +03:00
|
|
|
target_commitish = "$(Build.SourceVersion)";
|
2023-11-08 13:09:33 +03:00
|
|
|
name = "v$(AgentVersion)";
|
2020-08-20 23:13:39 +03:00
|
|
|
body = $releaseNotes;
|
|
|
|
draft = $false;
|
|
|
|
prerelease = $true;
|
2020-04-08 20:42:44 +03:00
|
|
|
}
|
2020-08-20 23:13:39 +03:00
|
|
|
$releaseParams = @{
|
|
|
|
Uri = "https://api.github.com/repos/Microsoft/azure-pipelines-agent/releases";
|
|
|
|
Method = 'POST';
|
|
|
|
Headers = @{
|
|
|
|
Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("vsts:$(GithubToken)"));
|
|
|
|
}
|
|
|
|
ContentType = 'application/json';
|
|
|
|
Body = (ConvertTo-Json $releaseData -Compress)
|
2020-04-08 20:42:44 +03:00
|
|
|
}
|
2020-08-20 23:13:39 +03:00
|
|
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
|
|
|
$releaseCreated = Invoke-RestMethod @releaseParams
|
|
|
|
Write-Host $releaseCreated
|
|
|
|
$releaseId = $releaseCreated.id
|
2024-07-12 16:19:38 +03:00
|
|
|
Write-Host "##vso[task.setVariable variable=releaseId;isoutput=true]$releaseId"
|
2023-11-08 13:09:33 +03:00
|
|
|
$assets = [System.IO.File]::ReadAllText("$(Build.SourcesDirectory)\assets.json").Replace("<AGENT_VERSION>","$(AgentVersion)")
|
2020-08-20 23:13:39 +03:00
|
|
|
$assetsParams = @{
|
|
|
|
Uri = "https://uploads.github.com/repos/Microsoft/azure-pipelines-agent/releases/$releaseId/assets?name=assets.json"
|
|
|
|
Method = 'POST';
|
|
|
|
Headers = @{
|
|
|
|
Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("vsts:$(GithubToken)"));
|
|
|
|
}
|
|
|
|
ContentType = 'application/octet-stream';
|
|
|
|
Body = [system.Text.Encoding]::UTF8.GetBytes($assets)
|
|
|
|
}
|
|
|
|
Invoke-RestMethod @assetsParams
|
|
|
|
displayName: Create agent release on Github
|
2024-07-12 16:19:38 +03:00
|
|
|
name: create_github_release
|
|
|
|
|
|
|
|
# Delete test agent release
|
|
|
|
- powershell: |
|
|
|
|
Write-Host "Deleting test github release."
|
|
|
|
$releaseId = $(create_github_release.releaseId)
|
|
|
|
|
|
|
|
$releaseParams = @{
|
|
|
|
Uri = "https://api.github.com/repos/Microsoft/azure-pipelines-agent/releases/$releaseId";
|
|
|
|
Method = 'DELETE';
|
|
|
|
Headers = @{
|
|
|
|
Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("vsts:$(GithubToken)"));
|
|
|
|
}
|
|
|
|
ContentType = 'application/json';
|
|
|
|
}
|
|
|
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
|
|
|
$releaseDeleted = Invoke-RestMethod @releaseParams
|
|
|
|
Write-Host $releaseDeleted.Id
|
|
|
|
displayName: Delete test agent release from Github
|
|
|
|
condition: and(succeeded(), eq(variables.IsTestRun, 'True'))
|
|
|
|
|
2024-07-29 12:32:06 +03:00
|
|
|
- stage: Cleanup_Release_Branch
|
|
|
|
displayName: Cleanup Release Branch
|
|
|
|
dependsOn:
|
|
|
|
- Verify_release
|
|
|
|
- Create_Release_Branch
|
|
|
|
- Release
|
|
|
|
condition: always()
|
|
|
|
jobs:
|
|
|
|
- job: Delete_Release_Branch
|
|
|
|
displayName: Delete Release Branch
|
|
|
|
variables:
|
|
|
|
IsTestRun: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.isTestRun'] ]
|
|
|
|
condition: eq(variables.IsTestRun, 'True')
|
|
|
|
|
|
|
|
pool:
|
|
|
|
name: 1ES-ABTT-Shared-Pool
|
|
|
|
image: abtt-ubuntu-2204
|
|
|
|
os: linux
|
|
|
|
steps:
|
|
|
|
- checkout: self
|
|
|
|
|
2024-07-12 16:19:38 +03:00
|
|
|
- powershell: |
|
|
|
|
git config --global user.email "azure-pipelines-bot@microsoft.com"
|
|
|
|
git config --global user.name "azure-pipelines-bot"
|
|
|
|
git status
|
2024-07-29 12:32:06 +03:00
|
|
|
|
|
|
|
$testBranch = "releases/3.000.999"
|
|
|
|
$testTag = "v3.000.999"
|
|
|
|
|
|
|
|
if (git ls-remote --heads origin $testBranch) {
|
|
|
|
git -c credential.helper='!f() { echo "username=pat"; echo "password=$(GithubToken)"; };f' push origin --delete $testBranch
|
|
|
|
}
|
|
|
|
|
|
|
|
if (git ls-remote --tags origin $testTag) {
|
|
|
|
git -c credential.helper='!f() { echo "username=pat"; echo "password=$(GithubToken)"; };f' push --delete origin $testTag
|
|
|
|
}
|
2024-07-12 16:19:38 +03:00
|
|
|
displayName: Clean up test release branch
|
2020-04-08 20:42:44 +03:00
|
|
|
|
2023-11-08 13:09:33 +03:00
|
|
|
- stage: CreatePRs
|
|
|
|
dependsOn:
|
|
|
|
- Release
|
|
|
|
- Verify_release
|
|
|
|
condition: and(succeeded(), not(${{ parameters.onlyGitHubRelease }}))
|
2023-11-23 13:28:37 +03:00
|
|
|
pool:
|
2024-02-28 15:41:50 +03:00
|
|
|
name: 1ES-ABTT-Shared-Pool
|
|
|
|
image: abtt-mariner
|
|
|
|
os: linux
|
2023-11-08 13:09:33 +03:00
|
|
|
jobs:
|
|
|
|
################################################################################
|
|
|
|
- job: create_ado_prs
|
|
|
|
################################################################################
|
|
|
|
displayName: Create PRs in AzureDevOps and ConfigChange
|
|
|
|
variables:
|
2024-07-12 16:19:38 +03:00
|
|
|
IsTestRun: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.isTestRun'] ]
|
2023-11-08 13:09:33 +03:00
|
|
|
IsRelease: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.isRelease'] ]
|
|
|
|
ReleaseBranch: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.releaseBranch'] ]
|
|
|
|
AgentVersion: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.agentVersion'] ]
|
2024-07-12 16:19:38 +03:00
|
|
|
condition: and(succeeded(), or(eq(variables.IsRelease, 'True'), eq(variables.IsTestRun, 'True')))
|
2023-11-08 13:09:33 +03:00
|
|
|
steps:
|
|
|
|
- checkout: self
|
|
|
|
|
|
|
|
- ${{ if eq(variables['Build.SourceBranch'], 'refs/heads/master') }}:
|
|
|
|
- script: git checkout $(ReleaseBranch)
|
|
|
|
displayName: Checkout release branch
|
|
|
|
|
|
|
|
# Download all agent hashes created in previous phases
|
|
|
|
- task: DownloadBuildArtifacts@0
|
|
|
|
displayName: Download Agent Hashes
|
|
|
|
inputs:
|
|
|
|
artifactName: hash
|
|
|
|
downloadPath: $(Build.SourcesDirectory)/_hashes
|
|
|
|
|
2024-06-24 15:53:35 +03:00
|
|
|
- template: /.azure-pipelines/get-pat.yml@self
|
|
|
|
|
2023-11-08 13:09:33 +03:00
|
|
|
- bash: |
|
|
|
|
set -x
|
|
|
|
cd release
|
|
|
|
npm install
|
|
|
|
ls
|
2024-07-29 12:32:06 +03:00
|
|
|
node createAdoPrs.js $(AgentVersion) --dryrun="$(IsTestRun)"
|
2023-11-23 13:28:37 +03:00
|
|
|
name: s_CreateAdoPrs
|
2022-11-03 15:55:03 +03:00
|
|
|
displayName: Create PRs in AzureDevOps and ConfigChange
|
2023-11-08 13:09:33 +03:00
|
|
|
env:
|
|
|
|
USERNAME: $(User)
|
2024-06-24 15:53:35 +03:00
|
|
|
PAT: $(ACCESS_TOKEN)
|
2023-11-08 13:09:33 +03:00
|
|
|
USEREMAIL: $(Email)
|
2023-11-23 13:28:37 +03:00
|
|
|
|
2023-12-21 15:06:51 +03:00
|
|
|
- stage: S_Notifications
|
|
|
|
displayName: Notifications
|
|
|
|
dependsOn:
|
|
|
|
- Verify_release
|
|
|
|
- CreatePRs
|
|
|
|
pool:
|
2024-02-28 15:41:50 +03:00
|
|
|
name: 1ES-ABTT-Shared-Pool
|
|
|
|
image: abtt-ubuntu-2204
|
|
|
|
os: linux
|
2023-12-21 15:06:51 +03:00
|
|
|
jobs:
|
|
|
|
- job: j_SendPRsNotifications
|
|
|
|
displayName: Send Release PRs notifications
|
2023-12-14 20:15:57 +03:00
|
|
|
variables:
|
2024-07-12 16:19:38 +03:00
|
|
|
IsTestRun: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.isTestRun'] ]
|
2023-12-14 20:15:57 +03:00
|
|
|
IsRelease: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.isRelease'] ]
|
2023-12-21 15:06:51 +03:00
|
|
|
AdoPrId: $[ stageDependencies.CreatePRs.create_ado_prs.outputs['s_CreateAdoPrs.AdoPrId'] ]
|
|
|
|
AdoPrLink: $[ stageDependencies.CreatePRs.create_ado_prs.outputs['s_CreateAdoPrs.AdoPrLink'] ]
|
|
|
|
CcPrId: $[ stageDependencies.CreatePRs.create_ado_prs.outputs['s_CreateAdoPrs.CcPrId'] ]
|
|
|
|
CcPrLink: $[ stageDependencies.CreatePRs.create_ado_prs.outputs['s_CreateAdoPrs.CcPrLink'] ]
|
|
|
|
condition: |
|
|
|
|
and(
|
2024-02-28 15:41:50 +03:00
|
|
|
not(${{ parameters.disableNotifications }}),
|
2023-12-21 15:06:51 +03:00
|
|
|
eq(variables.IsRelease, 'True'),
|
2024-07-12 16:19:38 +03:00
|
|
|
eq(variables.IsTestRun, 'False'),
|
2023-12-21 15:06:51 +03:00
|
|
|
not(${{ parameters.onlyGitHubRelease }})
|
|
|
|
)
|
2023-11-23 13:28:37 +03:00
|
|
|
steps:
|
2023-12-21 15:06:51 +03:00
|
|
|
- task: PowerShell@2
|
|
|
|
inputs:
|
|
|
|
targetType: 'filePath'
|
|
|
|
filePath: ./release/Send-PRsNotification.ps1
|
2023-11-23 13:28:37 +03:00
|
|
|
displayName: Send MS Teams notification
|
|
|
|
env:
|
2023-12-21 15:06:51 +03:00
|
|
|
TEAMS_WEBHOOK: $(MsTeamsWebhook)
|
|
|
|
ADO_PR_ID: $(AdoPrId)
|
|
|
|
ADO_PR_LINK: $(AdoPrLink)
|
|
|
|
CC_PR_ID: $(CcPrId)
|
|
|
|
CC_PR_LINK: $(CcPrLink)
|