From 93a135a92c6c769a99b31fe6309a1ea7cb82df0e Mon Sep 17 00:00:00 2001 From: Nicola Suter <32899754+nicolonsky@users.noreply.github.com> Date: Wed, 26 Aug 2020 16:18:11 +0200 Subject: [PATCH] CI/CD pipeline (#5) Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 83 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 66 insertions(+), 17 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 23eb3c8..ceed69e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -3,22 +3,71 @@ trigger: - refs/tags/* -pool: - vmImage: windows-latest +variables: + - group: NuGetApiKey + - name: 'moduleName' + value: 'AzureADLicensing' -steps: - - task: PowerShell@2 - inputs: - targetType: 'inline' - script: | - Install-Module InvokeBuild -Force - Install-Module PowerShellGet -Force - Install-Module ModuleBuilder -Force - Install-Module Pester -Force +stages: + - stage: Build + jobs: + - job: Build + pool: + vmImage: 'windows-latest' + steps: + - task: PowerShell@2 + inputs: + targetType: 'inline' + script: | + Install-Module InvokeBuild -Force + Install-Module PowerShellGet -Force + Install-Module ModuleBuilder -Force + Install-Module Pester -Force - Invoke-Build - - task: PublishBuildArtifacts@1 - inputs: - PathtoPublish: 'bin' - ArtifactName: 'AzureADLicensing-Module' - publishLocation: 'Container' \ No newline at end of file + Invoke-Build + - task: PublishBuildArtifacts@1 + inputs: + PathtoPublish: 'bin' + ArtifactName: '$(moduleName)-Module' + publishLocation: 'Container' + + - stage: Deploy + jobs: + - deployment: 'Deploy' + displayName: 'Publish to PSGallery and GitHub' + pool: + vmImage: 'windows-latest' + environment: 'production' + strategy: + runOnce: + deploy: + steps: + - checkout: none + - task: DownloadBuildArtifacts@0 + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: '$(moduleName)-Module' + downloadPath: '$(System.ArtifactsDirectory)' + - task: ArchiveFiles@2 + inputs: + rootFolderOrFile: '$(System.ArtifactsDirectory)/$(moduleName)-Module/$(moduleName)' + includeRootFolder: true + archiveType: 'zip' + archiveFile: '$(moduleName).zip' + replaceExistingArchive: true + verbose: true + - task: GitHubRelease@1 + displayName: 'Create GitHub release' + inputs: + gitHubConnection: GitHub + tagPattern: 'v*.*' + assets: '*.zip' + - task: PowerShell@2 + displayName: 'Publish to PowerShell Gallery' + inputs: + targetType: 'inline' + script: | + Install-Module Az.Accounts -Force + Publish-Module -Path ".\*\" -NuGetApiKey $(NuGetApiKey) + workingDirectory: '$(System.ArtifactsDirectory)/$(moduleName)-Module/$(moduleName)' \ No newline at end of file