-
Notifications
You must be signed in to change notification settings - Fork 6
/
azure-pipelines.yml
108 lines (103 loc) · 3.99 KB
/
azure-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
trigger:
- '*'
- refs/tags/v*.*
variables:
versionPrefix: 2.8
isTag: ${{ startsWith(variables['Build.SourceBranch'], 'refs/tags/v') }}
isHeku: ${{ eq(variables['Build.RequestedFor'], 'Heku') }}
shouldRelease: ${{ and(eq(variables.isHeku, 'True'), eq(variables.isTag, 'True')) }}
${{ if eq(variables.shouldRelease, 'True') }}:
tagVersion: ${{ replace(variables['Build.SourceBranchName'], 'v', '') }}
# https://learn.microsoft.com/en-us/azure/devops/pipelines/process/run-number?view=azure-devops&tabs=yaml
name: ${{ coalesce(variables.tagVersion, '$(versionPrefix).$(Rev:r)') }}
jobs:
- job: build
pool:
vmImage: windows-latest
variables:
solution: '**/*.sln'
buildPlatform: Any CPU
buildConfiguration: Release
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
displayName: Nuget restore
inputs:
restoreSolution: $(solution)
- task: PowerShell@2
displayName: Update versions
inputs:
targetType: inline
script: |
Import-Module -Force -Verbose .\vsix.psm1
UpdateVersion $(Build.BuildNumber)
- task: VSBuild@1
displayName: Build solution
inputs:
maximumCpuCount: true
solution: $(solution)
platform: $(BuildPlatform)
configuration: $(BuildConfiguration)
msbuildArchitecture: x64
msbuildArgs: /v:m /p:DeployExtension=false /p:ZipPackageCompressionLevel=normal
- task: CopyFiles@2
displayName: Copy files to ArtifactStagingDirectory
inputs:
Contents: |
vsix.psm1
publish.*
Screenshots/*
TargetFolder: $(Build.ArtifactStagingDirectory)
CleanTargetFolder: true
- task: PowerShell@2
displayName: Copy files to ArtifactStagingDirectory
inputs:
targetType: inline
script: |
Move-Item -Verbose *2019\bin\$(BuildConfiguration)\*.vsix $(Build.ArtifactStagingDirectory)\VsDiff.2019.vsix
Move-Item -Verbose *2022\bin\$(BuildConfiguration)\*.vsix $(Build.ArtifactStagingDirectory)\VsDiff.2022.vsix
- task: PublishBuildArtifacts@1
displayName: Publish artifacts
inputs:
PathtoPublish: $(Build.ArtifactStagingDirectory)
ArtifactName: staging
publishLocation: Container
# https://learn.microsoft.com/en-us/azure/devops/pipelines/process/deployment-jobs?view=azure-devops
- deployment: publish
dependsOn: build
pool:
vmImage: windows-latest
# https://learn.microsoft.com/en-us/azure/devops/pipelines/library/variable-groups?view=azure-devops&tabs=yaml#use-a-variable-group
variables:
- group: variables-group
condition: ${{ eq(variables.shouldRelease, 'True') }}
environment: publish-vsix
strategy:
runOnce:
deploy:
steps:
- task: GitHubRelease@1
displayName: Create GitHub release
inputs:
gitHubConnection: github.com_heku
repositoryName: $(Build.Repository.Name)
action: edit
target: $(Build.SourceVersion)
tag: $(Build.SourceBranchName)
# https://learn.microsoft.com/en-us/azure/devops/pipelines/artifacts/pipeline-artifacts?view=azure-devops&tabs=yaml#use-artifacts-across-stages
assets: $(Pipeline.Workspace)/staging/*.vsix
changeLogCompareToRelease: lastFullRelease
changeLogType: commitBased
- task: PowerShell@2
displayName: Push to marketplace
env:
# To use a secret variable in a script, you must explicitly map it as an environment variable.
# https://learn.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch#secret-variables
PERSONAL_ACCESS_TOKEN: $(PERSONAL_ACCESS_TOKEN)
inputs:
workingDirectory: $(Pipeline.Workspace)/staging
targetType: inline
script: |
Import-Module -Force -Verbose .\vsix.psm1
PublishVsix $env:PERSONAL_ACCESS_TOKEN *.2019.vsix publish.manifest.2019.json
PublishVsix $env:PERSONAL_ACCESS_TOKEN *.2022.vsix publish.manifest.2022.json