Skip to content

Commit b3bb804

Browse files
committed
Merge branch 'main' into yanxu/release-network-2023-04-01
2 parents 3e10ad1 + 81d8f8b commit b3bb804

File tree

6,619 files changed

+1198187
-429433
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

6,619 files changed

+1198187
-429433
lines changed

.azure-pipelines/code-oob.yml

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
parameters:
2+
- name: ServiceName
3+
displayName: OOB release Service
4+
type: string
5+
default: Databricks
6+
- name: Preview
7+
displayName: Is preview version? (version is "x.y.z-preview" or major version is 0)
8+
type: boolean
9+
default: false
10+
variables:
11+
BumpUpBranch: none
12+
stages:
13+
- stage: OOBRelease
14+
displayName: OOBRelease
15+
jobs:
16+
- job: BumpUpVersion
17+
timeoutInMinutes: 180
18+
pool: pool-windows-2019
19+
variables:
20+
NeedBumpUp: true
21+
steps:
22+
- task: DotNetCoreCLI@2
23+
displayName: Build
24+
inputs:
25+
command: custom
26+
custom: msbuild
27+
arguments: 'build.proj "/t:Clean;Build" /p:Configuration=Release'
28+
- pwsh: |
29+
.\tools\RunVersionController.ps1 -ModuleName "Az.${{ parameters.ServiceName }}”
30+
displayName: 'Bump up version'
31+
- task: PowerShell@2
32+
displayName: get changelog info
33+
name: outputinfo
34+
inputs:
35+
targetType: 'inline'
36+
script: |
37+
$readme = Get-ChildItem -Path "./src/${{ parameters.ServiceName }}" -name ChangeLog.md -Recurse
38+
$mdContent = Get-Content -Path "src/${{ parameters.ServiceName }}/$readme" -Raw
39+
$pattern = '(?s)## Version (\d+\.\d+\.\d)+[\s\S]*?\n(.*?)(?=\n## Version \d+\.\d+\.\d+|$)'
40+
$matches = [regex]::Match($mdcontent, $pattern)
41+
$NeedBumpUp = $true
42+
if ($matches.Success) {
43+
$versionNumber = $matches.Groups[1].Value
44+
$versionChanges = $matches.Groups[2].Value.Trim()
45+
}
46+
if ($${{ parameters.Preview }} -and ([version]$versionNumber -ge [version]"1.0.0")) {
47+
$versionNumber += "-preview"
48+
echo "##vso[task.setvariable variable=NeedBumpUp]false"
49+
$NeedBumpUp = $false
50+
}
51+
$jsonData = @{
52+
ModuleName = "${{ parameters.ServiceName }}"
53+
VersionNumber = "$versionNumber"
54+
VersionChanges = "$versionChanges"
55+
IsPreview = “${{ parameters.Preview }}“
56+
}
57+
$jsonString = $jsonData | ConvertTo-Json
58+
$jsonString | Out-File -FilePath "VersionInfo.json"
59+
$folderPath = "OOB"
60+
$fileName = "VersionInfo.json"
61+
New-Item -ItemType Directory -Force -Path $folderPath | Out-Null
62+
$filePath = Join-Path -Path $folderPath -ChildPath $fileName
63+
$jsonString | Out-File -FilePath $filePath
64+
$content = @"
65+
The OOB build is ready. Please give it a test and let us know if it's OK to publish.
66+
67+
How to install:
68+
- Install the Az.Tools.Installer module.
69+
``````powershell
70+
Install-Module -Name Az.Tools.Installer -Repository PSGallery
71+
``````
72+
- Install the latest Az.Accounts module unless the OOB build requires a specific version.
73+
``````powershell
74+
Install-Module Az.Accounts -Repository PSGallery
75+
``````
76+
- Use Az.Tools.Installer to install the OOB build.
77+
``````powershell
78+
Install-AzModule -Path $(BlobUrl)/Az.${{ parameters.ServiceName }}.$versionNumber.nupkg
79+
``````
80+
81+
"@
82+
$readmePath = "OOB/README.md"
83+
$content | Out-File -FilePath $readmePath
84+
85+
if ($NeedBumpUp) {
86+
echo "##vso[task.setvariable variable=BumpUpBranch;isOutput=true]$(BranchPrefix)/${{ parameters.ServiceName }}"
87+
88+
} else {
89+
echo "##vso[task.setvariable variable=BumpUpBranch;isOutput=true]none"
90+
}
91+
- task: AzurePowerShell@5
92+
inputs:
93+
azureSubscription: '$(AzureSubscription)'
94+
ScriptType: 'InlineScript'
95+
azurePowerShellVersion: 'LatestVersion'
96+
inline: |
97+
Set-AzContext -Tenant $(TenantId) -SubscriptionId $(SubscriptionId)
98+
$Token = Get-AzKeyVaultSecret -VaultName $(KeyVaultName) -Name $(KeyVaultAccount) -AsPlainText
99+
git config user.email "$(GithubEmail)"
100+
git config user.name "$(GithubUsername)"
101+
git checkout -b $(BranchPrefix)/${{ parameters.ServiceName }}
102+
git add -A ':!OOB'
103+
if ($${{ parameters.Preview }}) {
104+
git reset -- ./tools/Tools.Common/SerializedCmdlets/Az.${{ parameters.ServiceName }}.json
105+
}
106+
git commit -m "Bump up version for ${{ parameters.ServiceName }}"
107+
git remote set-url origin https://azure-powershell-bot:[email protected]/Azure/azure-powershell.git;
108+
git push origin $(BranchPrefix)/${{ parameters.ServiceName }} --force;
109+
$Title = "${{ parameters.ServiceName }} OOB Release"
110+
$HeadBranch = "$(BranchPrefix)/${{ parameters.ServiceName }}"
111+
$BaseBranch = "$(Build.SourceBranch)"
112+
$BaseBranch = $BaseBranch.Replace("refs/heads/", "")
113+
$Description = "${{ parameters.ServiceName }} OOB Release"
114+
./tools/Github/CreatePR.ps1 -Title $Title -HeadBranch $HeadBranch -BaseBranch $BaseBranch -BotAccessToken $Token -Description $Description -Draft $true
115+
displayName: Create PR to main branch
116+
condition: and(succeeded(), eq(variables['NeedBumpUp'], 'true'))
117+
118+
119+
- task: PowerShell@2
120+
displayName: publish oob tools
121+
inputs:
122+
targetType: 'inline'
123+
script: |
124+
Copy-Item .\tools\ModulePublisher.psd1 -Destination OOB
125+
Copy-Item .\tools\ModulePublisher.psm1 -Destination OOB
126+
Copy-Item .\tools\NuGet.exe -Destination OOB
127+
- task: PublishBuildArtifacts@1
128+
inputs:
129+
PathtoPublish: OOB
130+
ArtifactName: OOB
131+
- stage: Codesign
132+
variables:
133+
BumpUpBranch: $[stageDependencies.OOBRelease.BumpUpVersion.outputs['outputinfo.BumpUpBranch']]
134+
dependsOn: OOBRelease
135+
jobs:
136+
- template: ./code-sign.yml
137+
parameters:
138+
OOBBranch: $(BumpUpBranch)
139+
- job: PulishForTest
140+
dependsOn: Release
141+
steps:
142+
- task: DownloadBuildArtifacts@1
143+
inputs:
144+
buildType: 'current'
145+
downloadType: 'single'
146+
artifactName: 'OOB'
147+
downloadPath: '$(System.ArtifactsDirectory)'
148+
- task: DownloadBuildArtifacts@1
149+
inputs:
150+
buildType: 'current'
151+
downloadType: 'single'
152+
artifactName: 'artifacts'
153+
downloadPath: '$(System.ArtifactsDirectory)'
154+
- task: AzurePowerShell@5
155+
displayName: 'Push packages to storage account'
156+
inputs:
157+
azureSubscription: '$(AzureSubscription)'
158+
ScriptType: InlineScript
159+
azurePowerShellVersion: LatestVersion
160+
pwsh: true
161+
Inline: |
162+
$jsonFilePath = "$(System.ArtifactsDirectory)/OOB/VersionInfo.json"
163+
$jsonContent = Get-Content -Path $jsonFilePath -Raw
164+
$jsonObject = $jsonContent | ConvertFrom-Json
165+
$versionNumber = $jsonObject.VersionNumber
166+
$versionChanges = $jsonObject.VersionChanges
167+
$moduleName = $jsonObject.ModuleName
168+
$context = New-AzStorageContext -StorageAccountName "$(TestStorageAccountName)"
169+
$package = Get-Item "$(System.ArtifactsDirectory)/artifacts/Az.$moduleName.$versionNumber.nupkg"
170+
$package | Set-AzStorageBlobContent -Container "public" -Context $context -Force

0 commit comments

Comments
 (0)