-
Notifications
You must be signed in to change notification settings - Fork 231
build(wrapper): add the internal-feed release pipeline and install guide (main) #3756
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
Open
Joywambui-maina
wants to merge
1
commit into
main
Choose a base branch
from
feat/wrapper-release-pipeline-main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+233
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,149 @@ | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. | ||
|
|
||
| name: $(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r) | ||
|
|
||
| parameters: | ||
| - name: BuildAgent | ||
| default: 1es-windows-ps-compute-m | ||
| displayName: Build Agent | ||
| - name: PackageVersion | ||
| type: string | ||
| default: 3.0.0 | ||
| displayName: Package version | ||
| - name: Sign | ||
| type: boolean | ||
| default: true | ||
| - name: Publish | ||
| type: boolean | ||
| default: false | ||
| - name: InternalFeed | ||
| type: string | ||
| # The feed is PROJECT-scoped (dev.azure.com/microsoftgraph/Graph Developer Experiences/ | ||
| # _artifacts/feed/MSGraph_PowerShell_V3_Build), so publishVstsFeed needs the project | ||
| # qualifier - a bare feed name only resolves for organization-scoped feeds. | ||
| default: Graph Developer Experiences/MSGraph_PowerShell_V3_Build | ||
| displayName: Internal NuGet feed | ||
|
|
||
| variables: | ||
| BuildAgent: ${{ parameters.BuildAgent }} | ||
| WrapperConfiguration: Release | ||
| WrapperPrerelease: alpha$(Build.BuildId) | ||
|
|
||
| trigger: none | ||
| pr: none | ||
|
|
||
| resources: | ||
| repositories: | ||
| - repository: 1ESPipelineTemplates | ||
| type: git | ||
| name: 1ESPipelineTemplates/1ESPipelineTemplates | ||
| ref: refs/tags/release | ||
|
|
||
| extends: | ||
| template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates | ||
| parameters: | ||
| pool: $(BuildAgent) | ||
| settings: | ||
| networkIsolationPolicy: Permissive | ||
| sdl: | ||
| binskim: | ||
| enabled: false | ||
| justificationForDisabling: "Matches sdk-release.yml; BinSkim currently blocks internal-feed publishing." | ||
| credscan: | ||
| suppressionsFile: $(Build.SourcesDirectory)/.azure-pipelines/config/credscan/credscan-suppressions.json | ||
| policheck: | ||
| exclusionFile: $(Build.SourcesDirectory)/.azure-pipelines/config/policheck/policheck-exclusions.xml | ||
| customBuildTags: | ||
| - ES365AIMigrationTooling | ||
| stages: | ||
| - stage: Build | ||
| displayName: Build wrapper modules | ||
| jobs: | ||
| - job: Wrapper_Build | ||
| displayName: Generate, build, pack, and sign wrapper modules | ||
| timeoutInMinutes: 840 | ||
| templateContext: | ||
| outputs: | ||
| - output: pipelineArtifact | ||
| displayName: Publish wrapper module artifacts | ||
| targetPath: $(Build.ArtifactStagingDirectory) | ||
| artifactName: drop | ||
| publishLocation: Container | ||
| steps: | ||
| - script: git submodule update --init --recursive | ||
| displayName: Initialize submodules | ||
|
|
||
| - template: .azure-pipelines/common-templates/install-tools.yml@self | ||
| - template: .azure-pipelines/common-templates/security-pre-checks.yml@self | ||
|
|
||
| # Version and prerelease go to the script directly (-ModuleVersion/-Prerelease); the | ||
| # script owns package identity. Nothing here edits ModuleMetadata.json - that file | ||
| # belongs to the v2 release train. | ||
| - task: PowerShell@2 | ||
| displayName: Build and pack wrapper modules | ||
| inputs: | ||
| targetType: inline | ||
| pwsh: true | ||
| script: | | ||
| $params = @{ | ||
| ApiVersion = 'v1.0' | ||
| Configuration = '$(WrapperConfiguration)' | ||
| ArtifactsLocation = '$(Build.ArtifactStagingDirectory)' | ||
| ModuleVersion = '${{ parameters.PackageVersion }}' | ||
| Prerelease = '$(WrapperPrerelease)' | ||
| SkipKiota = $true | ||
| Pack = $true | ||
| } | ||
| & '$(Build.SourcesDirectory)/tools/Build-WrapperModule.ps1' @params | ||
| if ($LASTEXITCODE -ne 0) { throw "Wrapper build failed with exit code $LASTEXITCODE." } | ||
|
|
||
| - task: PowerShell@2 | ||
| displayName: Verify wrapper packages were produced | ||
| inputs: | ||
| targetType: inline | ||
| pwsh: true | ||
| script: | | ||
| $packages = @(Get-ChildItem '$(Build.ArtifactStagingDirectory)' -Recurse -Filter 'Microsoft.Graph.Wrapper.*.nupkg') | ||
| Write-Host "Wrapper packages produced: $($packages.Count)" | ||
| $packages | ForEach-Object { Write-Host " $($_.FullName)" } | ||
| if ($packages.Count -eq 0) { throw 'No wrapper packages were produced.' } | ||
|
|
||
| - template: .azure-pipelines/common-templates/guardian-analyzer.yml@self | ||
|
|
||
| - ${{ if eq(parameters.Sign, true) }}: | ||
| - template: .azure-pipelines/common-templates/esrp/codesign-nuget.yml@self | ||
| parameters: | ||
| FolderPath: $(Build.ArtifactStagingDirectory) | ||
| Pattern: Microsoft.Graph.Wrapper.*.nupkg | ||
|
|
||
| - template: .azure-pipelines/common-templates/security-post-checks.yml@self | ||
|
|
||
| - ${{ if eq(parameters.Publish, true) }}: | ||
| - stage: Deploy_to_Internal_Feed | ||
| displayName: Deploy wrapper packages to internal feed | ||
| dependsOn: Build | ||
| jobs: | ||
| - deployment: DeployToInternalFeed | ||
| displayName: Publish to MSGraph PowerShell V3 build feed | ||
| environment: PowerShellInternalFeed | ||
| templateContext: | ||
| type: releaseJob | ||
| isProduction: true | ||
| inputs: | ||
| - input: pipelineArtifact | ||
| artifactName: drop | ||
| targetPath: $(System.DefaultWorkingDirectory)/drop | ||
| strategy: | ||
| runOnce: | ||
| deploy: | ||
| steps: | ||
| - task: 1ES.PublishNuget@1 | ||
| displayName: Publish wrapper packages to internal feed | ||
| inputs: | ||
| useDotNetTask: false | ||
| packageParentPath: $(System.DefaultWorkingDirectory) | ||
| packagesToPush: $(System.DefaultWorkingDirectory)/**/drop/**/Microsoft.Graph.Wrapper.*.nupkg | ||
| publishVstsFeed: ${{ parameters.InternalFeed }} | ||
| nuGetFeedType: internal | ||
| allowPackageConflicts: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| # Install wrapper modules from the internal feed | ||
|
|
||
| The wrapper release pipeline publishes `Microsoft.Graph.Wrapper.*` prerelease packages to the | ||
| `MSGraph_PowerShell_V3_Build` Azure Artifacts feed for team validation. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Access to the Azure DevOps project and read permission on the feed. | ||
| - PowerShellGet 2.x. | ||
| - `Microsoft.Graph.Authentication` installed at the version used by the build. | ||
|
|
||
| Get the feed's NuGet v2 URL from **Azure Artifacts > Connect to feed > NuGet > v2**. PowerShellGet | ||
| 2.x requires the v2 endpoint when registering a `PSRepository`. | ||
|
|
||
| ## Register the feed | ||
|
|
||
| Use an Azure DevOps personal access token with Packaging Read permission. Enter the token only at | ||
| the secure prompt; do not put it in a script, command history, or source-controlled file. | ||
|
|
||
| ```powershell | ||
| $secureToken = Read-Host 'Azure DevOps PAT (Packaging: Read)' -AsSecureString | ||
| $credential = [pscredential]::new('AzureDevOps', $secureToken) | ||
| $feedUrl = 'https://pkgs.dev.azure.com/<organization>/<project>/_packaging/MSGraph_PowerShell_V3_Build/nuget/v2' | ||
|
|
||
| Register-PSRepository ` | ||
| -Name MSGraphPowerShellV3Build ` | ||
| -SourceLocation $feedUrl ` | ||
| -PublishLocation $feedUrl ` | ||
| -InstallationPolicy Trusted ` | ||
| -Credential $credential | ||
| ``` | ||
|
|
||
| Replace `<organization>/<project>` with the values from **Connect to feed**. Do not infer them from | ||
| the feed's display name. | ||
|
|
||
| ## Install and validate a package | ||
|
|
||
| Every pipeline run publishes a version such as `3.0.0-alpha12345`. `-AllowPrerelease` is therefore | ||
| required. | ||
|
|
||
| ```powershell | ||
| Install-Module Microsoft.Graph.Authentication -Scope CurrentUser -Force | ||
|
|
||
| Install-Module ` | ||
| -Name Microsoft.Graph.Wrapper.Users ` | ||
| -Repository MSGraphPowerShellV3Build ` | ||
| -Credential $credential ` | ||
| -AllowPrerelease ` | ||
| -Scope CurrentUser ` | ||
| -Force | ||
|
|
||
| Import-Module Microsoft.Graph.Wrapper.Users -Force | ||
|
|
||
| $module = Get-Module Microsoft.Graph.Wrapper.Users | ||
| $commands = @(Get-Command -Module $module.Name) | ||
| if (-not $module -or $commands.Count -eq 0) { | ||
| throw 'The wrapper module did not import or export any commands.' | ||
| } | ||
|
|
||
| $module | Select-Object Name, Version, Path | ||
| Write-Host "Exported commands: $($commands.Count)" | ||
| ``` | ||
|
|
||
| For an operation test, start a clean PowerShell process, import only the wrapper module under test, | ||
| connect with the least privileges needed, and invoke a read-only command. Loading the shipping and | ||
| wrapper workload modules together can create command-name conflicts, even though their module and | ||
| package IDs differ. | ||
|
|
||
| ## Find or update packages | ||
|
|
||
| ```powershell | ||
| Find-Module Microsoft.Graph.Wrapper.* ` | ||
| -Repository MSGraphPowerShellV3Build ` | ||
| -Credential $credential ` | ||
| -AllowPrerelease | ||
|
|
||
| Update-Module Microsoft.Graph.Wrapper.Users -AllowPrerelease -Force | ||
| ``` | ||
|
|
||
| Remove the repository registration when testing is complete: | ||
|
|
||
| ```powershell | ||
| Unregister-PSRepository -Name MSGraphPowerShellV3Build | ||
| ``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to include the markdown for main. We are only interested in the yml pipeline for main.