From bbb3a7f9c91c24267f21c9ee7f4ce44b5219dfbf Mon Sep 17 00:00:00 2001 From: Gael Date: Mon, 8 Nov 2021 23:41:08 +0100 Subject: [PATCH] updating pipeline with latest ubuntu and gitversion fix (#20) * updating pipeline with latest ubuntu and gitversion fix * fix gitversion var name --- CHANGELOG.md | 1 + azure-pipelines.yml | 22 +++++--- build.ps1 | 56 +++++++++++-------- .../en-US/about_Sampler.GitHubTasks.help.txt | 10 ++-- 4 files changed, 51 insertions(+), 38 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2655a41..263e0c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,3 +32,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed typo when adding debug output for GH task. - Fixed using the `Set-SamplerTaskVariable` in GH tasks. +- Fixed the Azure DevOps pipeline to build on Ubunt latest. diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 61a7281..ce936b5 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -17,14 +17,18 @@ stages: - job: Package_Module displayName: 'Package Module' pool: - vmImage: 'ubuntu 16.04' + vmImage: 'ubuntu-latest' steps: - - task: GitVersion@5 + - pwsh: | + dotnet tool install --global GitVersion.Tool + $gitVersionObject = dotnet-gitversion | ConvertFrom-Json + $gitVersionObject.psobject.properties.Foreach{ + Write-Host -Object "Setting Task Variable '$($_.Name)' with value '$($_.Value)'." + Write-Host -Object "##vso[task.setvariable variable=$($_.Name);]$($_.Value)" + } + Write-Host -Object "##vso[build.updatebuildnumber]$($gitVersionObject.FullSemVer)" + displayName: Calculate ModuleVersion (GitVersion) name: gitVersion - displayName: 'Evaluate Next Version' - inputs: - runtime: 'core' - configFilePath: 'GitVersion.yml' - task: PowerShell@2 name: package @@ -34,7 +38,7 @@ stages: arguments: '-ResolveDependency -tasks pack' pwsh: true env: - ModuleVersion: $(gitVersion.NuGetVersionV2) + ModuleVersion: $(NuGetVersionV2) - task: PublishPipelineArtifact@1 displayName: 'Publish Pipeline Artifact' @@ -51,7 +55,7 @@ stages: displayName: 'Linux' timeoutInMinutes: 0 pool: - vmImage: 'ubuntu 16.04' + vmImage: 'ubuntu-latest' steps: - task: DownloadPipelineArtifact@2 displayName: 'Download Pipeline Artifact' @@ -238,7 +242,7 @@ stages: - job: Deploy_Module displayName: 'Deploy Module' pool: - vmImage: 'ubuntu 16.04' + vmImage: 'ubuntu-latest' steps: - task: DownloadPipelineArtifact@2 displayName: 'Download Pipeline Artifact' diff --git a/build.ps1 b/build.ps1 index 4704a75..19da5e4 100644 --- a/build.ps1 +++ b/build.ps1 @@ -224,6 +224,38 @@ process Set-BuildHeader -Script ([scriptblock]::Create($BuildInfo.TaskHeader)) } + <# + Add BuildModuleOutput to PSModule Path environment variable. + Moved here (not in begin block) because build file can contains BuiltSubModuleDirectory value. + #> + if ($BuiltModuleSubdirectory) + { + if (-not (Split-Path -IsAbsolute -Path $BuiltModuleSubdirectory)) + { + $BuildModuleOutput = Join-Path -Path $OutputDirectory -ChildPath $BuiltModuleSubdirectory + } + else + { + $BuildModuleOutput = $BuiltModuleSubdirectory + } + } # test if BuiltModuleSubDirectory set in build config file + elseif ($BuildInfo.ContainsKey('BuiltModuleSubDirectory')) + { + $BuildModuleOutput = Join-Path -Path $OutputDirectory -ChildPath $BuildInfo['BuiltModuleSubdirectory'] + } + else + { + $BuildModuleOutput = $OutputDirectory + } + + # Pre-pending $BuildModuleOutput folder to PSModulePath to resolve built module from this folder. + if ($powerShellModulePaths -notcontains $BuildModuleOutput) + { + Write-Host -Object "[build] Pre-pending '$BuildModuleOutput' folder to PSModulePath" -ForegroundColor Green + + $env:PSModulePath = $BuildModuleOutput + [System.IO.Path]::PathSeparator + $env:PSModulePath + } + <# Import Tasks from modules via their exported aliases when defined in Build Manifest. https://github.com/nightroman/Invoke-Build/tree/master/Tasks/Import#example-2-import-from-a-module-with-tasks @@ -408,30 +440,6 @@ Begin } } - if ($BuiltModuleSubdirectory) - { - if (-not (Split-Path -IsAbsolute -Path $BuiltModuleSubdirectory)) - { - $BuildModuleOutput = Join-Path -Path $OutputDirectory -ChildPath $BuiltModuleSubdirectory - } - else - { - $BuildModuleOutput = $BuiltModuleSubdirectory - } - } - else - { - $BuildModuleOutput = $OutputDirectory - } - - # Pre-pending $BuildModuleOutput folder to PSModulePath to resolve built module from this folder. - if ($powerShellModulePaths -notcontains $BuildModuleOutput) - { - Write-Host -Object "[pre-build] Pre-pending '$BuildModuleOutput' folder to PSModulePath" -ForegroundColor Green - - $env:PSModulePath = $BuildModuleOutput + [System.IO.Path]::PathSeparator + $env:PSModulePath - } - <# The variable $PSDependTarget will be used below when building the splatting variable before calling Resolve-Dependency.ps1, unless overridden in the diff --git a/source/en-US/about_Sampler.GitHubTasks.help.txt b/source/en-US/about_Sampler.GitHubTasks.help.txt index 2ea2e46..6baaf3f 100644 --- a/source/en-US/about_Sampler.GitHubTasks.help.txt +++ b/source/en-US/about_Sampler.GitHubTasks.help.txt @@ -5,10 +5,11 @@ SHORT DESCRIPTION Sampler tasks for GitHub integrations LONG DESCRIPTION - {{ Add Long description here }} + This modules contains tasks to publish Release and artifacts to GitHub, and to create pull request to changelog. + This is to be used with the Sampler pipeline. EXAMPLES - PS C:\> {{ add examples here }} + PS C:\> ./build.ps1 -Tasks Publish_release_to_GitHub NOTE: Thank you to all those who contributed to this module, by writing code, sharing opinions, and provided feedback. @@ -17,8 +18,7 @@ TROUBLESHOOTING NOTE: Look out on the Github repository for issues and new releases. SEE ALSO - - {{ Please add Project URI such as github }}} + - https://github.com/gaelcolas/Sampler KEYWORDS - {{ Add coma separated keywords here }} - + Sampler, GitHub, template, plater, tasks, InvokeBuild