|
| 1 | +parameters: |
| 2 | + - name: SanitizedExtensionId |
| 3 | + type: string |
| 4 | + - name: AzdExtensionId |
| 5 | + type: string |
| 6 | + |
| 7 | +stages: |
| 8 | + - stage: PublishForPR |
| 9 | + dependsOn: Sign |
| 10 | + condition: >- |
| 11 | + and( |
| 12 | + succeeded(), |
| 13 | + ne(variables['Skip.Release'], 'true'), |
| 14 | + or( |
| 15 | + eq('PullRequest', variables['BuildReasonOverride']), |
| 16 | + and( |
| 17 | + eq('', variables['BuildReasonOverride']), |
| 18 | + eq(variables['Build.Reason'], 'PullRequest') |
| 19 | + ) |
| 20 | + ) |
| 21 | + ) |
| 22 | +
|
| 23 | + variables: |
| 24 | + - template: /eng/pipelines/templates/variables/image.yml |
| 25 | + - template: /eng/pipelines/templates/variables/globals.yml |
| 26 | + |
| 27 | + jobs: |
| 28 | + - deployment: Publish_Extension_For_PR |
| 29 | + environment: none |
| 30 | + |
| 31 | + pool: |
| 32 | + name: azsdk-pool |
| 33 | + image: ubuntu-22.04 |
| 34 | + os: linux |
| 35 | + |
| 36 | + templateContext: |
| 37 | + type: releaseJob |
| 38 | + isProduction: false |
| 39 | + inputs: |
| 40 | + - input: pipelineArtifact |
| 41 | + artifactName: release |
| 42 | + targetPath: release |
| 43 | + - input: pipelineArtifact |
| 44 | + artifactName: release-metadata |
| 45 | + targetPath: release-metadata |
| 46 | + |
| 47 | + strategy: |
| 48 | + runOnce: |
| 49 | + deploy: |
| 50 | + steps: |
| 51 | + - pwsh: | |
| 52 | + $PRNumber = '$(System.PullRequest.PullRequestNumber)' |
| 53 | + if ($env:PRNUMBEROVERRIDE) { |
| 54 | + Write-Host "PR Number override: $($env:PRNUMBEROVERRIDE)" |
| 55 | + $PRNumber = "$($env:PRNUMBEROVERRIDE)" |
| 56 | + } |
| 57 | + if (-not $PRNumber -or $PRNumber -match '^\$\(') { |
| 58 | + Write-Error "PR number could not be determined. Ensure this runs in a PR build or set PRNUMBEROVERRIDE." |
| 59 | + exit 1 |
| 60 | + } |
| 61 | + Write-Host "##vso[task.setvariable variable=PRNumber]$PRNumber" |
| 62 | + displayName: Set PR Number Variable |
| 63 | +
|
| 64 | + - template: /eng/pipelines/templates/steps/extension-set-metadata-variables.yml |
| 65 | + parameters: |
| 66 | + Use1ESArtifactTask: true |
| 67 | + |
| 68 | + - template: /eng/pipelines/templates/steps/publish-extension.yml |
| 69 | + parameters: |
| 70 | + PublishUploadLocations: ${{ parameters.SanitizedExtensionId }}/pr/$(PRNumber) |
| 71 | + CreateGitHubRelease: false |
| 72 | + |
| 73 | + - template: /eng/pipelines/templates/steps/update-extension-pr-registry.yml |
| 74 | + parameters: |
| 75 | + SanitizedExtensionId: ${{ parameters.SanitizedExtensionId }} |
| 76 | + AzdExtensionId: ${{ parameters.AzdExtensionId }} |
| 77 | + PRNumber: $(PRNumber) |
| 78 | + |
| 79 | + - pwsh: | |
| 80 | + $storageHost = "$(publish-storage-static-host)" |
| 81 | + $extId = "${{ parameters.AzdExtensionId }}" |
| 82 | + $sanitizedId = "${{ parameters.SanitizedExtensionId }}" |
| 83 | + $prNumber = "$(PRNumber)" |
| 84 | + $registryUrl = "$storageHost/azd/extensions/pr-registry-entries/$prNumber/$extId.json" |
| 85 | + $binaryBase = "$storageHost/azd/extensions/$sanitizedId/pr/$prNumber" |
| 86 | +
|
| 87 | + $content = @" |
| 88 | + <!-- #comment-ext-pr-$extId --> |
| 89 | + ## azd Extension Install Instructions — ``$extId`` |
| 90 | +
|
| 91 | + > :warning: **These are unsigned PR builds for testing only.** Do not use in production. |
| 92 | +
|
| 93 | + ### Install from PR build |
| 94 | +
|
| 95 | + ``````bash |
| 96 | + azd ext source add -n pr-$prNumber -t url -l "$registryUrl" |
| 97 | + azd ext install $extId --source pr-$prNumber |
| 98 | + `````` |
| 99 | +
|
| 100 | + ### Standalone Binaries |
| 101 | +
|
| 102 | + | Platform | Download | |
| 103 | + |----------|----------| |
| 104 | + | Linux x86_64 | $binaryBase/$sanitizedId-linux-amd64.tar.gz | |
| 105 | + | Linux ARM64 | $binaryBase/$sanitizedId-linux-arm64.tar.gz | |
| 106 | + | macOS x86_64 | $binaryBase/$sanitizedId-darwin-amd64.zip | |
| 107 | + | macOS ARM64 | $binaryBase/$sanitizedId-darwin-arm64.zip | |
| 108 | + | Windows x86_64 | $binaryBase/$sanitizedId-windows-amd64.zip | |
| 109 | + | Windows ARM64 | $binaryBase/$sanitizedId-windows-arm64.zip | |
| 110 | + "@ |
| 111 | + $file = New-TemporaryFile |
| 112 | + Set-Content -Path $file -Value $content |
| 113 | + Write-Host "##vso[task.setvariable variable=CommentBodyFile]$file" |
| 114 | + displayName: Generate PR comment body |
| 115 | +
|
| 116 | + - template: /eng/pipelines/templates/steps/update-prcomment.yml |
| 117 | + parameters: |
| 118 | + PrNumber: $(PRNumber) |
| 119 | + BodyFile: $(CommentBodyFile) |
| 120 | + Tag: '<!-- #comment-ext-pr-${{ parameters.AzdExtensionId }} -->' |
0 commit comments