| 1 | parameters: |
| 2 | - name: publishPackage |
| 3 | type: boolean |
| 4 | default: false |
| 5 | |
| 6 | - name: packageVersion |
| 7 | type: string |
| 8 | default: '' |
| 9 | |
| 10 | - name: bypassTests |
| 11 | type: boolean |
| 12 | default: false |
| 13 | |
| 14 | - name: pushToStore |
| 15 | type: boolean |
| 16 | default: false |
| 17 | |
| 18 | stages: |
| 19 | - stage: flight |
| 20 | ${{ if eq(parameters.bypassTests, true) }}: |
| 21 | dependsOn: [package] |
| 22 | ${{ else }}: |
| 23 | dependsOn: [test, package] |
| 24 | |
| 25 | jobs: |
| 26 | - job: flight |
| 27 | displayName: 'Package and Flight WSL package' |
| 28 | |
| 29 | dependsOn: [] # The stage handles this dependency |
| 30 | pool: |
| 31 | type: windows |
| 32 | variables: |
| 33 | AppId: 9P9TQF7MRM4R |
| 34 | FlightId: $(StoreBrokerFlightId) |
| 35 | StoreBrokerPath: $(Build.SourcesDirectory)\storebroker # location of StoreBroker information in the repo |
| 36 | StoreBrokerPayloadPath: $(Build.ArtifactStagingDirectory)\StoreBrokerPayload # location of package created for flight |
| 37 | ob_outputDirectory: '$(Build.SourcesDirectory)\out' |
| 38 | ob_artifactBaseName: 'drop_wsl' |
| 39 | ob_artifactSuffix: '_flight' |
| 40 | ob_sdl_checkcflags_enabled : false # Disable the CFLAGS check since we're not actually building anything in this stage |
| 41 | |
| 42 | steps: |
| 43 | |
| 44 | # Source: https://learn.microsoft.com/azure/devops/pipelines/build/run-retention?view=azure-devops&tabs=powershell |
| 45 | - task: PowerShell@2 |
| 46 | condition: and(succeeded(), not(canceled())) |
| 47 | displayName: Retain this build |
| 48 | inputs: |
| 49 | failOnStderr: true |
| 50 | targetType: 'inline' |
| 51 | script: | |
| 52 | $contentType = "application/json"; |
| 53 | $headers = @{ Authorization = 'Bearer $(System.AccessToken)' }; |
| 54 | $rawRequest = @{ daysValid = 365 * 2; definitionId = $(System.DefinitionId); ownerId = 'User:$(Build.RequestedForId)'; protectPipeline = $false; runId = $(Build.BuildId) }; |
| 55 | $request = ConvertTo-Json @($rawRequest); |
| 56 | $uri = "$(System.CollectionUri)$(System.TeamProject)/_apis/build/retention/leases?api-version=6.0-preview.1"; |
| 57 | Invoke-RestMethod -uri $uri -method POST -Headers $headers -ContentType $contentType -Body $request; |
| 58 | |
| 59 | # Download the build drop |
| 60 | - task: DownloadPipelineArtifact@2 |
| 61 | displayName: Download package artifact |
| 62 | inputs: |
| 63 | artifact: "drop_wsl_package" |
| 64 | path: drop |
| 65 | |
| 66 | # copy the appxupload folder to the storebroker folder |
| 67 | - powershell: | |
| 68 | mkdir $(StoreBrokerPath)\appxpackage\ |
| 69 | Copy-Item -Path drop\appxupload\* -Destination $(StoreBrokerPath)\appxpackage\ -Recurse -Force |
| 70 | displayName: Copy AppxUpload artifact |
| 71 | |
| 72 | # creates a submission package that is published to the store; containers store page information and the WSL appxupload |
| 73 | - task: MS-RDX-MRO.windows-store-publish.package-task.store-package@3 |
| 74 | displayName: 'Creating StoreBroker Payload' |
| 75 | inputs: |
| 76 | serviceEndpoint: 'AzureConnection-StoreBroker-WIF' |
| 77 | sbConfigPath: $(StoreBrokerPath)\sbconfig.json |
| 78 | sourceFolder: $(StoreBrokerPath)\appxpackage\ |
| 79 | contents: Microsoft.WSL_${{ parameters.packageVersion }}.0_x64_ARM64.appxupload |
| 80 | pdpPath: $(StoreBrokerPath)\PDPs\ |
| 81 | pdpInclude: PDP.xml |
| 82 | pdpMediaPath: $(StoreBrokerPath)\Media\ |
| 83 | outSBPackagePath: $(StoreBrokerPayloadPath) |
| 84 | outSBName: WindowsSubsystemForLinux |
| 85 | |
| 86 | # copy the storebroker submission package to the drop folder so it can be used if needed |
| 87 | - powershell: | |
| 88 | New-Item -ItemType Directory -Force -Path $(ob_outputDirectory) |
| 89 | Copy-Item -Path $(StoreBrokerPayloadPath)\* -Destination $(ob_outputDirectory) -Recurse -Force |
| 90 | Copy-Item -Path SBLog.txt -Destination $(ob_outputDirectory) -Force |
| 91 | displayName: Copy StoreBrokerPayload to drop |
| 92 | |
| 93 | # submit the package flight to the WSL SelfHost Flight Group |
| 94 | - task: MS-RDX-MRO.windows-store-publish.flight-task.store-flight@3 |
| 95 | displayName: 'Flight StoreBroker Package to Partner Center - WSL SelfHost Flight Group' |
| 96 | condition: and(succeeded(), eq('${{ parameters.publishPackage }}', true), eq('${{ parameters.pushToStore }}', true)) |
| 97 | inputs: |
| 98 | serviceEndpoint: 'AzureConnection-StoreBroker-WIF' |
| 99 | appId: $(AppId) |
| 100 | flightId: $(FlightId) |
| 101 | inputMethod: JsonAndZip |
| 102 | jsonPath: $(StoreBrokerPayloadPath)\WindowsSubsystemForLinux.json |
| 103 | zipPath: $(StoreBrokerPayloadPath)\WindowsSubsystemForLinux.zip |
| 104 | force: true |
| 105 | skipPolling: true # skips polling Partner Centre/store API for the state of the package; skipping will mean that errors in the process will only show up in Partner Center |
| 106 | targetPublishMode: Immediate # on completion of this task, the package will be published to the WSL SelfHost flight once certified (no manual clicking of any buttons in Partner Center) |
| 107 | preserveSubmissionId: false |
| 108 | deletePackages: true |
| 109 | numberOfPackagesToKeep: 0 |
| 110 | |
| 111 | - task: PipAuthenticate@1 |
| 112 | displayName: 'Pip Authenticate' |
| 113 | inputs: |
| 114 | artifactFeeds: 'wsl' |
| 115 | |
| 116 | - task: AzureKeyVault@2 |
| 117 | displayName: Fetch GitHub release token from Key Vault |
| 118 | inputs: |
| 119 | azureSubscription: 'Azure-Connection' |
| 120 | KeyVaultName: 'wsl-ci-key-vault' |
| 121 | SecretsFilter: 'GithubReleaseToken' |
| 122 | |
| 123 | # Create a draft github release |
| 124 | - powershell: | |
| 125 | pip install --user -r tools/devops/requirements.txt |
| 126 | python tools/devops/create-release.py '${{ parameters.packageVersion }}' drop\bundle\Microsoft.WSL_${{ parameters.packageVersion }}.0_x64_ARM64.msixbundle drop\bundle\wsl.${{ parameters.packageVersion }}.0.arm64.msi drop\bundle\wsl.${{ parameters.packageVersion }}.0.x64.msi drop\nuget\Microsoft.WSL.Containers.${{ parameters.packageVersion }}.nupkg --no-fetch --github-token "$env:token" ${{ iif(parameters.publishPackage, '--publish --auto-release-notes', '--use-current-ref') }} |
| 127 | |
| 128 | displayName: Create GitHub release |
| 129 | env: |
| 130 | token: $(GithubReleaseToken) |