-
Notifications
You must be signed in to change notification settings - Fork 76
pipelines: Support working directory in sign step #2156
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,13 +4,16 @@ parameters: | |
| default: True | ||
| - name: vsixFileNames | ||
| type: object | ||
| default: [''] | ||
| default: [""] | ||
| - name: workingDirectory | ||
| type: string | ||
| default: "." | ||
|
|
||
| steps: | ||
| # Check if the SignExtension.signproj file exists and set a variable using PowerShell | ||
| # All other steps in this template will only run if the file exists | ||
| - powershell: | | ||
| $fileExists = Test-Path -Path "$(Build.SourcesDirectory)/.azure-pipelines/SignExtension.signproj" | ||
| $fileExists = Test-Path -Path "$(Build.SourcesDirectory)/${{ parameters.workingDirectory }}/.azure-pipelines/SignExtension.signproj" | ||
| Write-Output "##vso[task.setvariable variable=signprojExists]$fileExists" | ||
|
|
||
| if ($fileExists) { | ||
|
|
@@ -23,77 +26,83 @@ steps: | |
|
|
||
| # put the extension name and version from the package.json into variables to use later. Variables can be used in later steps as $(package.name) and $(package.version) | ||
| - pwsh: | | ||
| Write-Output "##vso[task.setvariable variable=name;isOutput=true]$((Get-Content -Raw -Path package.json | ConvertFrom-Json).name)" | ||
| Write-Output "##vso[task.setvariable variable=version;isOutput=true]$((Get-Content -Raw -Path package.json | ConvertFrom-Json).version)" | ||
| Write-Output "##vso[task.setvariable variable=name;isOutput=true]$((Get-Content -Raw -Path ${{ parameters.workingDirectory }}/package.json | ConvertFrom-Json).name)" | ||
| Write-Output "##vso[task.setvariable variable=version;isOutput=true]$((Get-Content -Raw -Path ${{ parameters.workingDirectory }}/package.json | ConvertFrom-Json).version)" | ||
| condition: and(succeeded(), eq(variables['signprojExists'], True)) | ||
| name: package | ||
| displayName: "\U0001F449 Get extension info from package.json" | ||
| workingDirectory: $(Build.SourcesDirectory) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a little confusing why this step happens at the root, but subsequent ones at
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Weird because it seems like it worked fine but I would've assumed this would break it https://dev.azure.com/devdiv/DevDiv/_build/results?buildId=12924123&view=artifacts&pathAsName=false&type=publishedArtifacts |
||
|
|
||
| # Sign single vsix file if vsixFileNames are not provided | ||
| - ${{ if eq(join('', parameters.vsixFileNames), '') }}: | ||
| - script: npx @vscode/vsce@latest generate-manifest -i $(package.name)-$(package.version).vsix -o $(Build.SourcesDirectory)/extension.manifest | ||
| condition: and(succeeded(), eq(variables['signprojExists'], True)) | ||
| displayName: "\U0001F449 Generate extension manifest" | ||
| - script: npx @vscode/vsce@latest generate-manifest -i $(package.name)-$(package.version).vsix -o $(Build.SourcesDirectory)/${{ parameters.workingDirectory }}/extension.manifest | ||
| condition: and(succeeded(), eq(variables['signprojExists'], True)) | ||
| displayName: "\U0001F449 Generate extension manifest" | ||
| workingDirectory: $(Build.SourcesDirectory)/${{ parameters.workingDirectory }} | ||
|
|
||
| # this task will pass even if signing fails, so we follow it up with a check to see if the signature file was created | ||
| - task: DotNetCoreCLI@2 | ||
| condition: and(succeeded(), eq(variables['signprojExists'], True)) | ||
| displayName: "\U0001F449 Sign with MSBuild" | ||
| inputs: | ||
| command: 'build' | ||
| projects: $(Build.SourcesDirectory)/.azure-pipelines/SignExtension.signproj | ||
| env: | ||
| SYSTEM_ACCESSTOKEN: $(System.AccessToken) | ||
| # this task will pass even if signing fails, so we follow it up with a check to see if the signature file was created | ||
| - task: DotNetCoreCLI@2 | ||
| condition: and(succeeded(), eq(variables['signprojExists'], True)) | ||
| displayName: "\U0001F449 Sign with MSBuild" | ||
| inputs: | ||
| command: "build" | ||
| projects: $(Build.SourcesDirectory)/${{ parameters.workingDirectory }}/.azure-pipelines/SignExtension.signproj | ||
| env: | ||
| SYSTEM_ACCESSTOKEN: $(System.AccessToken) | ||
|
|
||
| - pwsh: | | ||
| $filePath = "extension.signature.p7s" | ||
| - pwsh: | | ||
| $filePath = "extension.signature.p7s" | ||
|
|
||
| if (-Not (Test-Path $filePath)) { | ||
| Write-Error "The file '$filePath' does not exist." | ||
| exit 1 | ||
| } | ||
| if (-Not (Test-Path $filePath)) { | ||
| Write-Error "The file '$filePath' does not exist." | ||
| exit 1 | ||
| } | ||
|
|
||
| Write-Output "The file '$filePath' exists." | ||
| exit 0 | ||
| displayName: "\U0001F449 Verify extension.signature.p7s file was created" | ||
| condition: and(succeeded(), eq(variables['signprojExists'], True)) | ||
| Write-Output "The file '$filePath' exists." | ||
| exit 0 | ||
| displayName: "\U0001F449 Verify extension.signature.p7s file was created" | ||
| condition: and(succeeded(), eq(variables['signprojExists'], True)) | ||
| workingDirectory: $(Build.SourcesDirectory)/${{ parameters.workingDirectory }} | ||
|
|
||
| # If vsixFileNames are provided, sign each file in list and move to corresponding directory | ||
| - ${{ if ne(join('', parameters.vsixFileNames), '') }}: | ||
| # run this script for each item in vsixFileNames | ||
| - ${{ each vsixFileName in parameters.vsixFileNames }}: | ||
| - script: npx @vscode/vsce@latest generate-manifest -i ${{ vsixFileName }}-$(package.version).vsix -o $(Build.SourcesDirectory)/extension.manifest | ||
| condition: and(succeeded(), eq(variables['signprojExists'], True)) | ||
| displayName: "\U0001F449 Generate extension manifest for ${{ vsixFileName }}" | ||
| # run this script for each item in vsixFileNames | ||
| - ${{ each vsixFileName in parameters.vsixFileNames }}: | ||
| - script: npx @vscode/vsce@latest generate-manifest -i ${{ vsixFileName }}-$(package.version).vsix -o $(Build.SourcesDirectory)/${{ parameters.workingDirectory }}/extension.manifest | ||
| condition: and(succeeded(), eq(variables['signprojExists'], True)) | ||
| displayName: "\U0001F449 Generate extension manifest for ${{ vsixFileName }}" | ||
| workingDirectory: $(Build.SourcesDirectory)/${{ parameters.workingDirectory }} | ||
|
|
||
| # this task will pass even if signing fails, so we follow it up with a check to see if the signature file was created | ||
| - task: DotNetCoreCLI@2 | ||
| condition: and(succeeded(), eq(variables['signprojExists'], True)) | ||
| displayName: "\U0001F449 Sign with MSBuild for ${{ vsixFileName }}" | ||
| inputs: | ||
| command: 'build' | ||
| projects: $(Build.SourcesDirectory)/.azure-pipelines/SignExtension.signproj | ||
| env: | ||
| SYSTEM_ACCESSTOKEN: $(System.AccessToken) | ||
| # this task will pass even if signing fails, so we follow it up with a check to see if the signature file was created | ||
| - task: DotNetCoreCLI@2 | ||
| condition: and(succeeded(), eq(variables['signprojExists'], True)) | ||
| displayName: "\U0001F449 Sign with MSBuild for ${{ vsixFileName }}" | ||
| inputs: | ||
| command: "build" | ||
| projects: $(Build.SourcesDirectory)/${{ parameters.workingDirectory }}/.azure-pipelines/SignExtension.signproj | ||
| env: | ||
| SYSTEM_ACCESSTOKEN: $(System.AccessToken) | ||
|
|
||
| - pwsh: | | ||
| $filePath = "extension.signature.p7s" | ||
| - pwsh: | | ||
| $filePath = "extension.signature.p7s" | ||
|
|
||
| if (-Not (Test-Path $filePath)) { | ||
| Write-Error "The file '$filePath' does not exist." | ||
| exit 1 | ||
| } | ||
| if (-Not (Test-Path $filePath)) { | ||
| Write-Error "The file '$filePath' does not exist." | ||
| exit 1 | ||
| } | ||
|
|
||
| Write-Output "The file '$filePath' exists." | ||
| exit 0 | ||
| displayName: "\U0001F449 Verify extension.signature.p7s file was created for ${{ vsixFileName }}" | ||
| condition: and(succeeded(), eq(variables['signprojExists'], True)) | ||
| Write-Output "The file '$filePath' exists." | ||
| exit 0 | ||
| displayName: "\U0001F449 Verify extension.signature.p7s file was created for ${{ vsixFileName }}" | ||
| condition: and(succeeded(), eq(variables['signprojExists'], True)) | ||
| workingDirectory: $(Build.SourcesDirectory)/${{ parameters.workingDirectory }} | ||
|
|
||
| - pwsh: | | ||
| $targetDir = "${{ vsixFileName }}" | ||
| New-Item -ItemType Directory -Force -Path "$(Build.SourcesDirectory)/$targetDir" | ||
| Move-Item -Path "extension.signature.p7s" -Destination "$(Build.SourcesDirectory)/$targetDir/extension.signature.p7s" -Force | ||
| Move-Item -Path "extension.manifest" -Destination "$(Build.SourcesDirectory)/$targetDir/extension.manifest" -Force | ||
| Write-Output "Moved signature files to $targetDir directory" | ||
| displayName: "\U0001F449 Move signature files to ${{ vsixFileName }} directory" | ||
| condition: and(succeeded(), eq(variables['signprojExists'], True)) | ||
| - pwsh: | | ||
| $targetDir = "${{ vsixFileName }}" | ||
| New-Item -ItemType Directory -Force -Path "$(Build.SourcesDirectory)/${{ parameters.workingDirectory }}/$targetDir" | ||
| Move-Item -Path "extension.signature.p7s" -Destination "$(Build.SourcesDirectory)/${{ parameters.workingDirectory }}/$targetDir/extension.signature.p7s" -Force | ||
| Move-Item -Path "extension.manifest" -Destination "$(Build.SourcesDirectory)/${{ parameters.workingDirectory }}/$targetDir/extension.manifest" -Force | ||
| Write-Output "Moved signature files to $targetDir directory" | ||
| displayName: "\U0001F449 Move signature files to ${{ vsixFileName }} directory" | ||
| condition: and(succeeded(), eq(variables['signprojExists'], True)) | ||
| workingDirectory: $(Build.SourcesDirectory)/${{ parameters.workingDirectory }} | ||
Uh oh!
There was an error while loading. Please reload this page.