Skip to content

Weekly release update #507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jan 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .azure-pipelines/common-templates/checkout.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

steps:
- checkout: self
clean: true
fetchDepth: 1
persistCredentials: true

- task: PowerShell@2
displayName: "Configure user"
inputs:
targetType: "inline"
script: |
git config --global user.email "[email protected]"
git config --global user.name "Microsoft Graph DevX Tooling"

- task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@2
displayName: "Run CredScan"
inputs:
debugMode: false
137 changes: 137 additions & 0 deletions .azure-pipelines/common-templates/download-openapi-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

parameters:
- name: Branch
type: string
default: "WeeklyOpenApiDocsDownload"
- name: BaseBranch
type: string
default: "dev"

jobs:
- job: GetLatestDocs
displayName: Download OpenApiDocs
pool: MsGraphDevXAzureAgents
steps:
- template: ./checkout.yml

- template: ./install-tools.yml

- task: PowerShell@2
name: "ComputeBranch"
displayName: "Compute weekly branch name"
inputs:
targetType: inline
script: |
$branch = "{0}/{1}" -f "$(Branch)", (Get-Date -Format yyyyMMddHHmm)
Write-Host "##vso[task.setvariable variable=WeeklyBranch;isOutput=true]$branch"

- task: Bash@3
displayName: "Create weekly branch"
inputs:
targetType: inline
script: |
git status
git fetch --all
git checkout $(BaseBranch)
git branch $(ComputeBranch.WeeklyBranch)
git checkout $(ComputeBranch.WeeklyBranch)
git status

- task: PowerShell@2
displayName: Download v1.0 OpenApi docs
continueOnError: false
inputs:
filePath: "$(System.DefaultWorkingDirectory)/tools/UpdateOpenApi.ps1"
pwsh: true

- task: PowerShell@2
displayName: Download beta OpenApi docs
continueOnError: false
inputs:
filePath: "$(System.DefaultWorkingDirectory)/tools/UpdateOpenApi.ps1"
arguments: "-BetaGraphVersion"
pwsh: true

- task: PowerShell@2
name: OpenAPIDocDiff
displayName: Get OpenAPI docs diff
inputs:
pwsh: true
targetType: "inline"
script: |
$diff = git diff --name-only
$ModulesWithChanges = @{}
$diff | %{
if (($_ -match 'openApiDocs\/(v1.0|beta)\/(.*).yml') -and !$ModulesWithChanges.ContainsKey($matches.2))
{
$ModulesWithChanges.Add($matches.2, $matches.1)
}
}
$ModuleNames = $ModulesWithChanges.Keys
Write-Host "##vso[task.setvariable variable=ModulesWithChanges;isOutput=true]$ModuleNames"

- task: PowerShell@2
displayName: Generate profiles
condition: and(succeeded(), ne(variables['OpenAPIDocDiff.ModulesWithChanges'], ''))
continueOnError: false
inputs:
targetType: filePath
pwsh: true
filePath: $(System.DefaultWorkingDirectory)/tools/GenerateProfiles.ps1

- task: PowerShell@2
name: CalculateAndBumpModuleVersion
displayName: Calculate and bump module version
condition: and(succeeded(), ne(variables['OpenAPIDocDiff.ModulesWithChanges'], ''))
inputs:
pwsh: true
targetType: inline
script: |
# Calculate meta-module version
$MetaModule = Find-Module "Microsoft.Graph" -Repository PSGallery
$MetaModuleVersion = [System.Version]($MetaModule.Version)
$NewMetaModuleVersion = "$($MetaModuleVersion.Major).$($MetaModuleVersion.Minor + 1).$($MetaModuleVersion.Build)"
# Bump meta-module minor version
Write-Host "Bumping Microsoft.Graph to $NewMetaModuleVersion."
& "$(System.DefaultWorkingDirectory)\tools\SetMetaModuleVersion.ps1" -VersionNumber $NewMetaModuleVersion

# Calculate existing service module version
"$(OpenAPIDocDiff.ModulesWithChanges)" -split " " | ForEach-Object {
try {
$Module = Find-Module "Microsoft.Graph.$_" -Repository PSGallery -ErrorAction Stop
$ModuleVersion = [System.Version]($Module.Version)
$NewModuleVersion = "$($ModuleVersion.Major).$($ModuleVersion.Minor + 1).$($ModuleVersion.Build)"
Write-Host "Bumping $_ to $NewModuleVersion."
. "$(System.DefaultWorkingDirectory)\tools\SetServiceModuleVersion.ps1" -VersionNumber $NewModuleVersion -Modules $_
} catch {
if ($_.Exception.Message -like "No match*") {
Write-Warning "$_. Version will be set to $NewMetaModuleVersion."
}
}
}

# Calculate new service module version
$NewModuleReadMePath = Join-Path $(System.DefaultWorkingDirectory) "/tools/Templates/readme.md"
. "$(System.DefaultWorkingDirectory)\tools\WriteToModuleReadMe.ps1" -ReadMePath $NewModuleReadMePath -FieldName "module-version" -NewFieldValue $NewMetaModuleVersion

- task: Bash@3
displayName: Commit downloaded files
condition: and(succeeded(), ne(variables['OpenAPIDocDiff.ModulesWithChanges'], ''))
env:
GITHUB_TOKEN: $(GITHUB_TOKEN)
inputs:
targetType: inline
script: |
git status
git add .
git commit -m 'Weekly OpenApiDocs Download'
git status
git push --set-upstream origin $(ComputeBranch.WeeklyBranch)
git status

# References
# [0] https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables
# [1] https://hub.github.com/hub-pull-request.1.html
# https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token
79 changes: 79 additions & 0 deletions .azure-pipelines/common-templates/install-tools.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

steps:
- task: UseDotNet@2
displayName: "Use .NET Core SDK 2.x"
inputs:
debugMode: false
version: 2.x

- task: NuGetToolInstaller@1
displayName: Install Nuget 5.7
inputs:
versionSpec: 5.7.0
checkLatest: false # Optional

- task: NuGetAuthenticate@0
displayName: Authenticate NuGet

- task: PowerShell@2
displayName: Install Powershell core
inputs:
targetType: inline
script: |
dotnet tool update --global PowerShell
pwsh

- task: PowerShell@2
displayName: Version check
inputs:
targetType: inline
pwsh: true
script: |
Write-Host $PSVersionTable.PSVersion
Write-Host $host.Version
Write-Host (Get-Host).Version

- task: NodeTool@0
displayName: Install NodeJs 14.11.0
inputs:
versionSpec: "14.11.0"
checkLatest: true # Optional

- task: Npm@1
displayName: Install AutoRest
inputs:
command: "custom"
customCommand: "install -g autorest@latest"

- task: PowerShell@2
displayName: Install PowerShell dependencies
inputs:
targetType: inline
pwsh: true
errorActionPreference: "continue"
script: |
Install-Module "powershell-yaml" -Repository PSGallery -Force

- task: PowerShell@2
displayName: Register PS repository
enabled: false
inputs:
targetType: inline
pwsh: true
errorActionPreference: "continue"
script: |
$ErrorActionPreference = [System.Management.Automation.ActionPreference]::Continue
Get-PSRepository
$patToken = '$(NUGETFEEDKEY)' | ConvertTo-SecureString -AsPlainText -Force
$nugetFeed = '$(NUGETFEED)'
$user = '$(NUGETBUILDUSER)'
$credsAzureDevopsServices = New-Object System.Management.Automation.PSCredential($user, $patToken)
UnRegister-PackageSource -Name 'LocalNugetPackageSource' -ErrorAction Continue
UnRegister-PSRepository -Name 'LocalNugetFeed' -ErrorAction Continue
Register-PackageSource -Name 'LocalNugetPackageSource' -Location $nugetFeed -SkipValidate -Trusted -Verbose -ProviderName 'Nuget' -ErrorAction Continue
Register-PSRepository -Name 'LocalNugetFeed' -SourceLocation $nugetFeed -PublishLocation $nugetFeed -InstallationPolicy Trusted -Credential $credsAzureDevopsServices -PackageManagementProvider 'Nuget' -ErrorAction Continue
Get-PSRepository
Find-Module -Name Microsoft.Graph.Authentication -AllowPrerelease -Credential $credsAzureDevopsServices -AllVersions -Repository 'LocalNugetFeed'
Find-Module -Name Microsoft.Graph.Authentication -AllowPrerelease -Repository 'LocalNugetFeed'
71 changes: 0 additions & 71 deletions .azure-pipelines/download-openapidocs-template.yml

This file was deleted.

Loading