523 строки
18 KiB
YAML
523 строки
18 KiB
YAML
trigger:
|
|
branches:
|
|
include:
|
|
- main
|
|
- develop
|
|
- release-*
|
|
paths:
|
|
exclude:
|
|
- README.md
|
|
- LICENSE.md
|
|
- CHANGELOG*.md
|
|
- NuGet.Config
|
|
- .github_changelog_generator
|
|
- .gitignore
|
|
tags:
|
|
include:
|
|
- refs/tags/v*
|
|
|
|
# PR always trigger build
|
|
pr:
|
|
autoCancel: true
|
|
|
|
# add nf-tools repo to resources (for Azure Pipelines templates)
|
|
resources:
|
|
repositories:
|
|
- repository: templates
|
|
type: github
|
|
name: nanoframework/nf-tools
|
|
endpoint: nanoframework
|
|
|
|
jobs:
|
|
|
|
##############################
|
|
- job: Get_Build_Options
|
|
pool:
|
|
vmImage: 'windows-latest'
|
|
|
|
steps:
|
|
- checkout: self
|
|
|
|
# check which project(s) have changed
|
|
- powershell: |
|
|
git config --global user.email "nfbot"
|
|
git config --global user.name "nanoframework@outlook.com"
|
|
|
|
$auth = "basic $([System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(":$(GitHubToken)"))))"
|
|
|
|
$commit = Invoke-RestMethod -Uri "https://api.github.com/repos/nanoframework/nf-Visual-Studio-extension/commits/$(Build.SourceVersion)" -Header @{"Authorization"="$auth"} -ContentType "application/json" -Method GET
|
|
Write-host "Files changed:"
|
|
$commit.files | % {$_.filename}
|
|
|
|
# default values
|
|
echo "##vso[task.setvariable variable=BUILD_VS2019;isOutput=true]false"
|
|
echo "##vso[task.setvariable variable=BUILD_VS2022;isOutput=true]false"
|
|
|
|
if( ($commit.files.filename -like "*CSharp.AssemblyInfoTemplate*") -Or
|
|
($commit.files.filename -like "*CSharp.BlankApplication*") -Or
|
|
($commit.files.filename -like "*CSharp.ClassLibrary*") -Or
|
|
($commit.files.filename -like "*CSharp.ClassTemplate*") -Or
|
|
($commit.files.filename -like "*CSharp.ResourceTemplate*") -Or
|
|
($commit.files.filename -like "*CSharp.TestApplication*") -Or
|
|
($commit.files.filename -like "*Tools.BuildTasks-2019*") -Or
|
|
($commit.files.filename -like "*Tools.BuildTasks-2022*") -Or
|
|
($commit.files.filename -like "*vs-extension.shared*") -Or
|
|
($commit.files.filename -like "*azure-pipelines.yml")
|
|
)
|
|
{
|
|
# global changes, build both
|
|
echo "##vso[task.setvariable variable=BUILD_VS2019;isOutput=true]true"
|
|
echo "##vso[task.setvariable variable=BUILD_VS2022;isOutput=true]true"
|
|
}
|
|
else
|
|
{
|
|
if( $commit.files.filename -like "*nanoFramework.Tools.VisualStudio.sln")
|
|
{
|
|
# changes here impact VS2022 and VS2019
|
|
echo "##vso[task.setvariable variable=BUILD_VS2019;isOutput=true]true"
|
|
echo "##vso[task.setvariable variable=BUILD_VS2022;isOutput=true]true"
|
|
}
|
|
if( $commit.files.filename -like "*VisualStudio.Extension-2019/*" )
|
|
{
|
|
# changes here only impact VS2019
|
|
echo "##vso[task.setvariable variable=BUILD_VS2019;isOutput=true]true"
|
|
}
|
|
if( $commit.files.filename -like "*VisualStudio.Extension-2022/*" )
|
|
{
|
|
# changes here only impact VS2022
|
|
echo "##vso[task.setvariable variable=BUILD_VS2022;isOutput=true]true"
|
|
}
|
|
}
|
|
|
|
name: BuildOptions
|
|
displayName: Get what to build
|
|
condition: not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
|
|
|
|
- powershell: |
|
|
# read VS2019 manifest file
|
|
$vs2019Manifest = Get-Content VisualStudio.Extension-2019/source.extension.vsixmanifest -Encoding utf8
|
|
|
|
$VersionFormatChecks = $vs2019Manifest | Where-Object {$_.ToString() -match "(?>Version=""\|%CurrentProject%;GetBuildVersion\|"")"}
|
|
if($null -eq $VersionFormatChecks)
|
|
{
|
|
Write-Host "***************************************************"
|
|
Write-Host "* WRONG format on version in VS2019 manifest file *"
|
|
Write-Host "***************************************************"
|
|
exit 1
|
|
}
|
|
|
|
# read VS2022 manifest file
|
|
$vs2022Manifest = Get-Content VisualStudio.Extension-2022/source.extension.vsixmanifest -Encoding utf8
|
|
|
|
$VersionFormatChecks = $vs2022Manifest | Where-Object {$_.ToString() -match "(?>Version=""\|%CurrentProject%;GetBuildVersion\|"")"}
|
|
if($null -eq $VersionFormatChecks)
|
|
{
|
|
Write-Host "***************************************************"
|
|
Write-Host "* WRONG format on version in VS2022 manifest file *"
|
|
Write-Host "***************************************************"
|
|
exit 1
|
|
}
|
|
displayName: Check proper version format
|
|
|
|
######################
|
|
- job: VS2019
|
|
condition: >-
|
|
or(
|
|
eq(dependencies.Get_Build_Options.outputs['BuildOptions.BUILD_VS2019'], true),
|
|
eq(variables['BUILD_VS2019'], 'true'),
|
|
startsWith(variables['Build.SourceBranch'], 'refs/tags/v2019')
|
|
)
|
|
dependsOn:
|
|
- Get_Build_Options
|
|
|
|
pool:
|
|
vmImage: 'windows-latest'
|
|
|
|
variables:
|
|
DOTNET_NOLOGO: true
|
|
solution: 'VisualStudio.Extension-2019/VisualStudio.Extension-vs2019.csproj'
|
|
buildConfiguration: 'Release'
|
|
|
|
steps:
|
|
|
|
# need this here in order to persist GitHub credentials AND init submodules
|
|
- checkout: self
|
|
submodules: true
|
|
|
|
- script: |
|
|
git config --global user.email 'nanoframework@outlook.com'
|
|
git config --global user.name 'nfbot'
|
|
displayName: Setup git identity
|
|
|
|
- template: azure-pipelines-templates/install-nuget.yml@templates
|
|
|
|
- task: NuGetCommand@2
|
|
inputs:
|
|
restoreSolution: 'nanoFramework.Tools.VisualStudio.sln'
|
|
feedsToUse: config
|
|
nugetConfigPath: NuGet.config
|
|
verbosityRestore: quiet
|
|
|
|
- task: VSBuild@1
|
|
inputs:
|
|
solution: '$(solution)'
|
|
msbuildArgs: '/p:PublicRelease=true'
|
|
configuration: '$(buildConfiguration)'
|
|
maximumCpuCount: true
|
|
|
|
# we don't have tests (yet)
|
|
# - task: VSTest@2
|
|
# inputs:
|
|
# platform: '$(buildPlatform)'
|
|
# configuration: '$(buildConfiguration)'
|
|
|
|
- task: PowerShell@2
|
|
inputs:
|
|
targetType: 'inline'
|
|
script: |
|
|
$versionData = & nbgv get-version -f json -p VisualStudio.Extension-2019
|
|
$versionData =$versionData | ConvertFrom-Json
|
|
|
|
$version = $versionData.AssemblyVersion
|
|
|
|
Write-Host "VS2019 build version $version"
|
|
|
|
echo "##vso[task.setvariable variable=BUILD_VERSION;isOutput=true]$version"
|
|
condition: succeeded()
|
|
name: VS2019_Build
|
|
displayName: Store VS2019 build version
|
|
|
|
- task: CopyFiles@1
|
|
inputs:
|
|
sourceFolder: $(Build.SourcesDirectory)
|
|
Contents: |
|
|
**\*VS2019.Extension.vsix
|
|
**\vs2019-extension-manifest.json
|
|
**\vs2019-marketplace-overview.md
|
|
**\vs2019\debug-session.png
|
|
**\vs2019\starting-new-project.png
|
|
TargetFolder: '$(Build.ArtifactStagingDirectory)\vs2019'
|
|
flattenFolders: true
|
|
condition: succeeded()
|
|
displayName: Collecting VS2019 deployable artifacts
|
|
|
|
- task: DotNetCoreCLI@2
|
|
displayName: Install SignTool tool
|
|
condition: and( succeeded(), eq(variables['System.PullRequest.PullRequestId'], '') )
|
|
inputs:
|
|
command: custom
|
|
custom: tool
|
|
arguments: install --tool-path . SignClient
|
|
|
|
- pwsh: |
|
|
.\SignClient "Sign" `
|
|
--baseDirectory "$(Build.ArtifactStagingDirectory)\vs2019" `
|
|
--input "**\*.vsix" `
|
|
--config "$(Build.Repository.LocalPath)\config\SignClient.json" `
|
|
--filelist "$(Build.Repository.LocalPath)\config\filelist.txt" `
|
|
--user "$(SignClientUser)" `
|
|
--secret '$(SignClientSecret)' `
|
|
--name ".NET nanoFramework VS2019 Extension" `
|
|
--description ".NET nanoFramework VS2019 Extension" `
|
|
--descriptionUrl "https://github.com/$env:Build_Repository_Name"
|
|
displayName: Sign VS2019 packages
|
|
condition: and( succeeded(), eq(variables['System.PullRequest.PullRequestId'], '') )
|
|
|
|
# publish artifacts (only possible if this is not a PR originated on a fork)
|
|
- task: PublishBuildArtifacts@1
|
|
inputs:
|
|
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
|
|
ArtifactName: deployables
|
|
ArtifactType: Container
|
|
condition: and( succeeded(), ne(variables['system.pullrequest.isfork'], true) )
|
|
displayName: Publish deployables artifacts
|
|
|
|
# upload extension to Open VSIX Gallery (only possible if this is not a PR from a fork)
|
|
- task: PowerShell@2
|
|
displayName: Upload vsix to Open VSIX Gallery
|
|
condition: >-
|
|
and(
|
|
succeeded(),
|
|
ne(variables['system.pullrequest.isfork'], true),
|
|
eq(variables['System.PullRequest.PullRequestId'], '')
|
|
)
|
|
continueOnError: true
|
|
inputs:
|
|
targetType: 'inline'
|
|
script: |
|
|
|
|
$artifactsCollection = @("./*VS2019.Extension.vsix") | %{ Get-ChildItem -File . -Filter $_ -Recurse}
|
|
|
|
(new-object Net.WebClient).DownloadString("https://raw.github.com/madskristensen/ExtensionScripts/master/AppVeyor/vsix.ps1") | iex
|
|
|
|
foreach($file in $artifactsCollection)
|
|
{
|
|
"Uploading VSIX package to Open VSIX Gallery..." | Write-Host
|
|
|
|
Vsix-PublishToGallery $file
|
|
}
|
|
|
|
# create or update GitHub release
|
|
- task: GithubRelease@1
|
|
condition: >-
|
|
and(
|
|
succeeded(),
|
|
eq(variables['System.PullRequest.PullRequestId'], ''),
|
|
not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
|
|
)
|
|
displayName: Create/Update GitHub release
|
|
inputs:
|
|
gitHubConnection: 'github.com_nano-$(System.TeamProject)'
|
|
tagSource: userSpecifiedTag
|
|
tag: v$(VS2019_Build.BUILD_VERSION)
|
|
title: '.NET nanoFramework VS Extension v$(VS2019_Build.BUILD_VERSION)'
|
|
releaseNotesSource: inline
|
|
releaseNotesInline: '<br><br><h4>Install from Open VSIX Gallery development feed.</h4><br>The following Visual Studio Extension is available for install from this release:<br><br>:package: [nanoFramework VS2019 Extension](http://vsixgallery.com/extension/455f2be5-bb07-451e-b351-a9faf3018dc9)'
|
|
assets: '$(Build.ArtifactStagingDirectory)/**/*.vsix'
|
|
assetUploadMode: replace
|
|
isPreRelease: true
|
|
isDraft: true
|
|
addChangeLog: false
|
|
|
|
# create or update GitHub release ON tags from release or main branches
|
|
- task: GithubRelease@1
|
|
condition: >-
|
|
and(
|
|
succeeded(),
|
|
startsWith(variables['Build.SourceBranch'], 'refs/tags/v'),
|
|
contains(variables['Build.SourceBranch'], 'v2019'),
|
|
or(
|
|
eq(variables['Build.SourceBranchName'], 'main'),
|
|
contains(variables['Build.SourceBranchName'], 'release')
|
|
)
|
|
)
|
|
displayName: Create/Update GitHub stable release
|
|
inputs:
|
|
action: edit
|
|
gitHubConnection: 'github.com_nano-$(System.TeamProject)'
|
|
tagSource: userSpecifiedTag
|
|
tag: v$(VS2019_Build.BUILD_VERSION)
|
|
title: '.NET nanoFramework VS Extension v$(VS2019_Build.BUILD_VERSION)'
|
|
releaseNotesSource: inline
|
|
releaseNotesInline: '<br><br><h4>Install from Visual Studio Marketplace.</h4><br>The following Visual Studio Extension is available for install from this release:<br><br>:package: [.NET nanoFramework VS2019 Extension](https://marketplace.visualstudio.com/items?itemName=nanoframework.nanoFramework-VS2019-Extension)'
|
|
assets: '$(Build.ArtifactStagingDirectory)/**/*.vsix'
|
|
assetUploadMode: replace
|
|
isPreRelease: false
|
|
addChangeLog: false
|
|
|
|
######################
|
|
- job: VS2022
|
|
condition: >-
|
|
or(
|
|
eq(dependencies.Get_Build_Options.outputs['BuildOptions.BUILD_VS2022'], true),
|
|
eq(variables['BUILD_VS2022'], 'true'),
|
|
startsWith(variables['Build.SourceBranch'], 'refs/tags/v2022')
|
|
)
|
|
dependsOn:
|
|
- Get_Build_Options
|
|
|
|
pool:
|
|
vmImage: 'windows-latest'
|
|
|
|
variables:
|
|
DOTNET_NOLOGO: true
|
|
solution: 'VisualStudio.Extension-2022/VisualStudio.Extension-vs2022.csproj'
|
|
buildConfiguration: 'Release'
|
|
|
|
steps:
|
|
|
|
# need this here in order to persist GitHub credentials AND init submodules
|
|
- checkout: self
|
|
submodules: true
|
|
|
|
- script: |
|
|
git config --global user.email 'nanoframework@outlook.com'
|
|
git config --global user.name 'nfbot'
|
|
displayName: Setup git identity
|
|
|
|
- template: azure-pipelines-templates/install-nuget.yml@templates
|
|
|
|
- task: NuGetCommand@2
|
|
inputs:
|
|
restoreSolution: 'nanoFramework.Tools.VisualStudio.sln'
|
|
feedsToUse: config
|
|
nugetConfigPath: NuGet.config
|
|
verbosityRestore: quiet
|
|
|
|
- task: VSBuild@1
|
|
inputs:
|
|
solution: '$(solution)'
|
|
msbuildArgs: '/p:PublicRelease=true'
|
|
configuration: '$(buildConfiguration)'
|
|
maximumCpuCount: true
|
|
msbuildArchitecture: 'x64'
|
|
platform: 'x64'
|
|
|
|
# we don't have tests (yet)
|
|
# - task: VSTest@2
|
|
# inputs:
|
|
# platform: '$(buildPlatform)'
|
|
# configuration: '$(buildConfiguration)'
|
|
|
|
- task: PowerShell@2
|
|
inputs:
|
|
targetType: 'inline'
|
|
script: |
|
|
$versionData = & nbgv get-version -f json -p VisualStudio.Extension-2022
|
|
$versionData =$versionData | ConvertFrom-Json
|
|
|
|
$version = $versionData.AssemblyVersion
|
|
|
|
Write-Host "VS2022 build version $version"
|
|
|
|
echo "##vso[task.setvariable variable=BUILD_VERSION;isOutput=true]$version"
|
|
condition: succeeded()
|
|
name: VS2022_Build
|
|
displayName: Store VS2022 build version
|
|
|
|
- task: CopyFiles@1
|
|
inputs:
|
|
sourceFolder: $(Build.SourcesDirectory)
|
|
Contents: |
|
|
**\*VS2022.Extension.vsix
|
|
**\vs2022-extension-manifest.json
|
|
**\vs2022-marketplace-overview.md
|
|
**\vs2022\debug-session.png
|
|
**\vs2022\starting-new-project.png
|
|
TargetFolder: '$(Build.ArtifactStagingDirectory)\vs2022'
|
|
flattenFolders: true
|
|
condition: succeeded()
|
|
displayName: Collecting VS2022 deployable artifacts
|
|
|
|
- task: DotNetCoreCLI@2
|
|
displayName: Install SignTool tool
|
|
condition: and( succeeded(), eq(variables['System.PullRequest.PullRequestId'], '') )
|
|
inputs:
|
|
command: custom
|
|
custom: tool
|
|
arguments: install --tool-path . SignClient
|
|
- pwsh: |
|
|
.\SignClient "Sign" `
|
|
--baseDirectory "$(Build.ArtifactStagingDirectory)\vs2022" `
|
|
--input "**\*.vsix" `
|
|
--config "$(Build.Repository.LocalPath)\config\SignClient.json" `
|
|
--filelist "$(Build.Repository.LocalPath)\config\filelist.txt" `
|
|
--user "$(SignClientUser)" `
|
|
--secret '$(SignClientSecret)' `
|
|
--name ".NET nanoFramework VS2022 Extension" `
|
|
--description ".NET nanoFramework VS2022 Extension" `
|
|
--descriptionUrl "https://github.com/$env:Build_Repository_Name"
|
|
displayName: Sign VS2022 packages
|
|
condition: and( succeeded(), eq(variables['System.PullRequest.PullRequestId'], '') )
|
|
|
|
# publish artifacts (only possible if this is not a PR originated on a fork)
|
|
- task: PublishBuildArtifacts@1
|
|
inputs:
|
|
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
|
|
ArtifactName: deployables
|
|
ArtifactType: Container
|
|
condition: and( succeeded(), ne(variables['system.pullrequest.isfork'], true) )
|
|
displayName: Publish deployables artifacts
|
|
|
|
# upload extension to Open VSIX Gallery (only possible if this is not a PR from a fork)
|
|
- task: PowerShell@2
|
|
displayName: Upload vsix to Open VSIX Gallery
|
|
condition: >-
|
|
and(
|
|
succeeded(),
|
|
ne(variables['system.pullrequest.isfork'], true),
|
|
eq(variables['System.PullRequest.PullRequestId'], '')
|
|
)
|
|
continueOnError: true
|
|
inputs:
|
|
targetType: 'inline'
|
|
script: |
|
|
|
|
$artifactsCollection = @("./*VS2022.Extension.vsix") | %{ Get-ChildItem -File . -Filter $_ -Recurse}
|
|
|
|
(new-object Net.WebClient).DownloadString("https://raw.github.com/madskristensen/ExtensionScripts/master/AppVeyor/vsix.ps1") | iex
|
|
|
|
foreach($file in $artifactsCollection)
|
|
{
|
|
"Uploading VSIX package to Open VSIX Gallery..." | Write-Host
|
|
|
|
Vsix-PublishToGallery $file
|
|
}
|
|
|
|
# create or update GitHub release
|
|
- task: GithubRelease@1
|
|
condition: >-
|
|
and(
|
|
succeeded(),
|
|
eq(variables['System.PullRequest.PullRequestId'], ''),
|
|
not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
|
|
)
|
|
displayName: Create/Update GitHub release
|
|
inputs:
|
|
gitHubConnection: 'github.com_nano-$(System.TeamProject)'
|
|
tagSource: userSpecifiedTag
|
|
tag: v$(VS2022_Build.BUILD_VERSION)
|
|
title: '.NET nanoFramework VS Extension v$(VS2022_Build.BUILD_VERSION)'
|
|
releaseNotesSource: inline
|
|
releaseNotesInline: '<br><br><h4>Install from Open VSIX Gallery development feed.</h4><br>The following Visual Studio Extension is available for install from this release:<br><br>:package: [.NET nanoFramework VS2022 Extension](http://vsixgallery.com/extension/bf694e17-fa5f-4877-9317-6d3664b2689a)'
|
|
assets: '$(Build.ArtifactStagingDirectory)/**/*.vsix'
|
|
assetUploadMode: replace
|
|
isDraft: true
|
|
isPreRelease: true
|
|
addChangeLog: false
|
|
|
|
# create or update GitHub release ON tags from release or main branches
|
|
- task: GithubRelease@1
|
|
condition: >-
|
|
and(
|
|
succeeded(),
|
|
startsWith(variables['Build.SourceBranch'], 'refs/tags/v'),
|
|
contains(variables['Build.SourceBranch'], 'v2022'),
|
|
or(
|
|
eq(variables['Build.SourceBranchName'], 'main'),
|
|
contains(variables['Build.SourceBranchName'], 'release')
|
|
)
|
|
)
|
|
displayName: Create/Update GitHub stable release
|
|
inputs:
|
|
action: edit
|
|
gitHubConnection: 'github.com_nano-$(System.TeamProject)'
|
|
tagSource: userSpecifiedTag
|
|
tag: v$(VS2022_Build.BUILD_VERSION)
|
|
title: '.NET nanoFramework VS Extension v$(VS2022_Build.BUILD_VERSION)'
|
|
releaseNotesSource: inline
|
|
releaseNotesInline: '<br><br><h4>Install from Visual Studio Marketplace.</h4><br>The following Visual Studio Extension is available for install from this release:<br><br>:package: [.NET nanoFramework VS2022 Extension](https://marketplace.visualstudio.com/items?itemName=nanoframework.nanoFramework-VS2022-Extension)'
|
|
assets: '$(Build.ArtifactStagingDirectory)/**/*.vsix'
|
|
assetUploadMode: replace
|
|
isPreRelease: false
|
|
addChangeLog: false
|
|
|
|
##################################
|
|
# report build failure to Discord
|
|
- job: Report_Build_Failure
|
|
|
|
dependsOn:
|
|
- VS2019
|
|
- VS2022
|
|
condition: >-
|
|
or(
|
|
failed('VS2019'),
|
|
failed('VS2022')
|
|
)
|
|
|
|
pool:
|
|
vmImage: 'windows-latest'
|
|
|
|
steps:
|
|
|
|
- checkout: self
|
|
fetchDepth: 1
|
|
|
|
# step from template @ nf-tools repo
|
|
# report error
|
|
- template: azure-pipelines-templates/discord-webhook.yml@templates
|
|
parameters:
|
|
status: 'failure'
|
|
webhookUrl: '$(DiscordWebhook)'
|
|
message: ''
|