Skip to content

Pipeline-ify entire release process #3461

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 11 commits into from
Jul 28, 2021
Merged
22 changes: 16 additions & 6 deletions .vsts-ci/azure-pipelines-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,36 @@ variables:
value: 'true'

trigger:
batch: true
branches:
include:
- master

resources:
repositories:
- repository: PowerShellEditorServices
type: github
endpoint: GitHub
name: PowerShell/PowerShellEditorServices
ref: master

jobs:
- job: Windows
- job: Win2019
displayName: Windows Server 2019
pool:
vmImage: 'windows-2019'
vmImage: windows-2019
steps:
- template: templates/ci-general.yml

- job: macOS
displayName: macOS 10.15
pool:
vmImage: 'macOS-10.15'
vmImage: macOS-10.15
steps:
- template: templates/ci-general.yml

- job: Linux
- job: Ubuntu
displayName: Ubuntu 20.04
pool:
vmImage: 'Ubuntu-20.04'
vmImage: Ubuntu-20.04
steps:
- template: templates/ci-general.yml
85 changes: 65 additions & 20 deletions .vsts-ci/azure-pipelines-release.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: Release-$(Build.SourceBranchName)-$(Date:yyyyMMdd)$(Rev:.rr)

variables:
# Don't download unneeded packages
- name: DOTNET_SKIP_FIRST_TIME_EXPERIENCE
Expand All @@ -6,34 +8,77 @@ variables:
- name: DOTNET_CLI_TELEMETRY_OPTOUT
value: 'true'

trigger:
branches:
include:
- release/*
trigger: none

resources:
repositories:
- repository: ComplianceRepo
type: github
endpoint: ComplianceGHRepo
endpoint: GitHub
name: PowerShell/Compliance

- repository: PowerShellEditorServices
type: git
name: PowerShellEditorServices
ref: release

pipelines:
- pipeline: PowerShellEditorServices
source: PowerShellEditorServices
trigger:
branches:
include:
- release/*
tags:
- v*

jobs:
- job: 'ReleaseBuild'
displayName: 'Build release'
pool:
name: '1ES'
demands: ImageOverride -equals MMS2019
variables:
- group: ESRP
steps:
- template: templates/release-general.yml
- release

stages:
- stage: Build
displayName: Build the release
jobs:
- job: Build
pool:
vmImage: windows-2019
steps:
- template: templates/ci-general.yml
parameters:
usePipelineArtifact: true

- stage: Sign
displayName: Sign the release
jobs:
- job: Sign
pool:
name: 1ES
demands: ImageOverride -equals MMS2019
variables:
- group: ESRP
steps:
- template: templates/release-general.yml

- stage: PublishGitHub
displayName: Publish the draft release
jobs:
- deployment: Publish
environment: vscode-powershell-github
pool:
vmImage: ubuntu-latest
variables:
- group: Publish
strategy:
runOnce:
deploy:
steps:
- template: templates/publish-github.yml

- stage: PublishMarkets
displayName: Publish to marketplace and gallery
jobs:
- deployment: Publish
environment: vscode-powershell-markets
pool:
vmImage: ubuntu-latest
variables:
- group: Publish
strategy:
runOnce:
deploy:
steps:
- template: templates/publish-markets.yml
39 changes: 29 additions & 10 deletions .vsts-ci/misc-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,40 @@
name: PR-$(System.PullRequest.PullRequestNumber)-$(Date:yyyyMMdd)$(Rev:.rr)

trigger:
# Batch merge builds together while a merge build is running
batch: true
branches:
include:
- master
- legacy/1.x

pr:
branches:
include:
- master
- legacy/1.x
- master

resources:
- repo: self
clean: true
repositories:
- repository: ComplianceRepo
type: github
endpoint: GitHub
name: PowerShell/compliance

jobs:
- template: templates/credscan.yml
- job: Compliance
pool:
vmImage: windows-latest
steps:
- checkout: self
- checkout: ComplianceRepo
- template: ci-compliance.yml@ComplianceRepo
# NOTE: This enables our project to work with Visual Studio's Rich Navigation:
# https://visualstudio.microsoft.com/services/rich-code-navigation/
- job: RichCodeNav
pool:
vmImage: windows-latest
steps:
# TODO: Move to GitHub Action
- task: RichCodeNavIndexer@0
continueOnError: true
inputs:
serviceConnection: rich-nav
nugetServiceConnection: rich-nav-nuget
githubServiceConnection: PowerShell
languages: typescript,csharp
serviceEndpoint: https://prod.richnav.vsengsaas.visualstudio.com
110 changes: 56 additions & 54 deletions .vsts-ci/templates/ci-general.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,57 @@
parameters:
- name: usePipelineArtifact
type: boolean
default: false

steps:
# Setup
- powershell: |
Write-Host "Installing PowerShell Daily..."

# Use `AGENT_TEMPDIRECTORY` to make sure the downloaded PowerShell is cleaned up.
$powerShellPath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'powershell'
Invoke-WebRequest -Uri https://aka.ms/install-powershell.ps1 -OutFile ./install-powershell.ps1

./install-powershell.ps1 -Destination $powerShellPath -Daily

# Using `prependpath` to update the PATH just for this build.
Write-Host "##vso[task.prependpath]$powerShellPath"
continueOnError: true
displayName: Install PowerShell Daily

- pwsh: '$PSVersionTable'
displayName: Display PowerShell version information

- pwsh: Write-Host "##vso[build.updatebuildnumber]$env:BUILD_SOURCEBRANCHNAME-$env:BUILD_SOURCEVERSION-$((get-date).ToString("yyyyMMddhhmmss"))"
displayName: Set Build Name for Non-PR
condition: ne(variables['Build.Reason'], 'PullRequest')

# TODO: Use a submodule or some such so we can actually track a version here.
- pwsh: |
git clone https://github.com/PowerShell/PowerShellEditorServices.git ../PowerShellEditorServices
Install-Module InvokeBuild -Scope CurrentUser -Force
Install-Module PlatyPS -Scope CurrentUser -Force
New-Item -ItemType Directory $(Build.ArtifactStagingDirectory)/vscode-powershell

# Build
- pwsh: Invoke-Build

- task: PublishTestResults@2
inputs:
testRunner: JUnit
testResultsFiles: '**/test-results.xml'
condition: succeededOrFailed()

- task: PublishBuildArtifacts@1
inputs:
ArtifactName: vscode-powershell
PathtoPublish: '$(Build.ArtifactStagingDirectory)/vscode-powershell'

# Rich Navigation
- task: RichCodeNavIndexer@0
# Note, for now, this is Windows only.
condition: and(succeededOrFailed(), eq(variables['Agent.OS'], 'Windows_NT'))
continueOnError: true
inputs:
serviceConnection: 'rich-nav'
nugetServiceConnection: 'rich-nav-nuget'
githubServiceConnection: 'PowerShell'
languages: 'typescript,csharp'
serviceEndpoint: 'https://prod.richnav.vsengsaas.visualstudio.com'
- pwsh: $PSVersionTable
displayName: PowerShell version

- checkout: self

# NOTE: We either checkout the Git repo for PowerShellEditorServices, or we
# download a pre-built artifact from the triggering pipeline and extract it to
# the modules folder. In this way we do not accidentally build a release of the
# server from this pipeline.
- checkout: PowerShellEditorServices
condition: not(${{ parameters.usePipelineArtifact }})

- task: DownloadPipelineArtifact@2
condition: ${{ parameters.usePipelineArtifact }}
displayName: Download PowerShellEditorServices
inputs:
source: specific
project: PowerShellEditorServices
pipeline: 36
preferTriggeringPipeline: true
allowPartiallySucceededBuilds: true
artifact: PowerShellEditorServices

- task: ExtractFiles@1
condition: ${{ parameters.usePipelineArtifact }}
displayName: Extract PowerShellEditorServices module
inputs:
archiveFilePatterns: $(Pipeline.Workspace)/PowerShellEditorServices.zip
destinationFolder: $(Build.SourcesDirectory)/vscode-powershell/modules

- pwsh: |
Install-Module InvokeBuild -Scope CurrentUser -Force
Invoke-Build
Write-Host "##vso[task.setvariable variable=vsixPath]$(Resolve-Path powershell-*.vsix)"
displayName: Build and test
workingDirectory: $(Build.SourcesDirectory)/vscode-powershell

- publish: $(vsixPath)
artifact: vscode-powershell-vsix-$(System.JobId)
displayName: Publish extension artifact

- publish: $(Build.SourcesDirectory)/vscode-powershell/scripts/Install-VSCode.ps1
artifact: vscode-powershell-unsigned-script-$(System.JobId)
displayName: Publish unsigned script artifact

- task: PublishTestResults@2
displayName: Publish test results
inputs:
testRunner: JUnit
testResultsFiles: '**/test-results.xml'
condition: succeededOrFailed()
11 changes: 11 additions & 0 deletions .vsts-ci/templates/publish-github.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
steps:
- checkout: self

- download: current
artifact: vscode-powershell
displayName: Download signed artifacts

- pwsh: |
$(Build.SourcesDirectory)/tools/setupReleaseTools.ps1 -Token $(GitHubToken)
New-DraftRelease -RepositoryName vscode-powershell -Assets $(Pipeline.Workspace)/vscode-powershell/powershell-*.vsix,$(Pipeline.Workspace)/vscode-powershell/Install-VSCode.ps1
displayName: Drafting a GitHub Release
17 changes: 17 additions & 0 deletions .vsts-ci/templates/publish-markets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
steps:
- checkout: self

- download: current
artifact: vscode-powershell
displayName: Download signed artifacts

- pwsh: |
npm install -g vsce
vsce publish --packagePath $(Pipeline.Workspace)/powershell-*.vsix --pat $(VsceToken)
displayName: Publishing VSIX to VS Code Marketplace

# NOTE: We rarely update this script, so we can ignore errors from the gallery
# caused by us trying to re-publish an updated script.
- pwsh: |
Publish-Script -Path $(Pipeline.Workspace)/Install-VSCode.ps1 -ErrorAction Continue -NuGetApiKey $(GalleryToken)
displayName: Publishing Install-VSCode.ps1 to PowerShell Gallery
Loading