|
| 1 | +trigger: |
| 2 | +- main |
| 3 | + |
| 4 | +schedules: |
| 5 | +- cron: '18 11 * * 5' |
| 6 | + displayName: Weekly CodeQL |
| 7 | + branches: |
| 8 | + include: |
| 9 | + - main |
| 10 | + always: true |
| 11 | + |
| 12 | +parameters: |
| 13 | +- name: debug |
| 14 | + displayName: Enable debug output |
| 15 | + type: boolean |
| 16 | + default: false |
| 17 | +- name: OfficialBuild |
| 18 | + displayName: Use Official OneBranch template |
| 19 | + type: boolean |
| 20 | + default: true |
| 21 | +- name: Release |
| 22 | + displayName: Generate a release |
| 23 | + type: boolean |
| 24 | + default: false |
| 25 | + |
| 26 | +variables: |
| 27 | + system.debug: ${{ parameters.debug }} |
| 28 | + BuildConfiguration: Release |
| 29 | + WindowsContainerImage: onebranch.azurecr.io/windows/ltsc2022/vse2022:latest |
| 30 | + OneBranchTemplate: ${{ iif(parameters.OfficialBuild, 'v2/OneBranch.Official.CrossPlat.yml@templates', 'v2/OneBranch.NonOfficial.CrossPlat.yml@templates') }} |
| 31 | + |
| 32 | +resources: |
| 33 | + repositories: |
| 34 | + - repository: templates |
| 35 | + type: git |
| 36 | + name: OneBranch.Pipelines/GovernedTemplates |
| 37 | + ref: refs/heads/main |
| 38 | + |
| 39 | +extends: |
| 40 | + # https://aka.ms/obpipelines/templates |
| 41 | + template: ${{ variables.OneBranchTemplate }} |
| 42 | + parameters: |
| 43 | + globalSdl: # https://aka.ms/obpipelines/sdl |
| 44 | + asyncSdl: |
| 45 | + enabled: true |
| 46 | + forStages: [build] |
| 47 | + featureFlags: |
| 48 | + EnableCDPxPAT: false |
| 49 | + WindowsHostVersion: |
| 50 | + Version: 2022 |
| 51 | + Network: KS3 |
| 52 | + release: |
| 53 | + category: NonAzure |
| 54 | + stages: |
| 55 | + - stage: build |
| 56 | + jobs: |
| 57 | + - job: main |
| 58 | + displayName: Build package |
| 59 | + pool: |
| 60 | + type: windows |
| 61 | + variables: |
| 62 | + ob_outputDirectory: $(Build.SourcesDirectory)/out |
| 63 | + steps: |
| 64 | + - pwsh: | |
| 65 | + $manifest = Import-PowerShellDataFile ./src/PSDesiredStateConfiguration/PSDesiredStateConfiguration.psd1 |
| 66 | + $version = $manifest.ModuleVersion |
| 67 | + Write-Output "##vso[task.setvariable variable=version;isOutput=true]$version" |
| 68 | + name: package |
| 69 | + displayName: Get version from module manifest |
| 70 | + - task: onebranch.pipeline.version@1 |
| 71 | + displayName: Set OneBranch version |
| 72 | + inputs: |
| 73 | + system: Custom |
| 74 | + customVersion: $(package.version) |
| 75 | + - pwsh: ./tools/installPSResources.ps1 -PSRepository CFS |
| 76 | + displayName: Install PSResources |
| 77 | + - pwsh: ./build.ps1 -Clean -Build -Test |
| 78 | + displayName: Build |
| 79 | + - task: onebranch.pipeline.signing@1 |
| 80 | + displayName: Sign 1st-party files |
| 81 | + inputs: |
| 82 | + command: sign |
| 83 | + signing_profile: external_distribution |
| 84 | + search_root: $(Build.SourcesDirectory)/out |
| 85 | + files_to_sign: | |
| 86 | + **/*.psd1; |
| 87 | + **/*.psm1; |
| 88 | + - pwsh: ./build.ps1 -Publish |
| 89 | + displayName: Package module |
| 90 | + - task: onebranch.pipeline.signing@1 |
| 91 | + displayName: Sign NuGet package |
| 92 | + inputs: |
| 93 | + command: sign |
| 94 | + signing_profile: external_distribution |
| 95 | + search_root: $(Build.SourcesDirectory)/out |
| 96 | + files_to_sign: | |
| 97 | + *.nupkg |
| 98 | + - stage: release |
| 99 | + dependsOn: build |
| 100 | + condition: and(succeeded(), ${{ eq(parameters.Release, true) }}) |
| 101 | + variables: |
| 102 | + ob_release_environment: ${{ iif(parameters.OfficialBuild, 'Production', 'Test') }} |
| 103 | + version: $[ stageDependencies.build.main.outputs['package.version'] ] |
| 104 | + jobs: |
| 105 | + - job: github |
| 106 | + displayName: Publish draft to GitHub |
| 107 | + pool: |
| 108 | + type: release |
| 109 | + templateContext: |
| 110 | + inputs: |
| 111 | + - input: pipelineArtifact |
| 112 | + artifactName: drop_build_main |
| 113 | + steps: |
| 114 | + - task: GitHubRelease@1 |
| 115 | + displayName: Create GitHub release |
| 116 | + inputs: |
| 117 | + gitHubConnection: GitHub |
| 118 | + repositoryName: PowerShell/PSDesiredStateConfiguration |
| 119 | + target: main |
| 120 | + assets: $(Pipeline.Workspace)/PSDesiredStateConfiguration.$(version).nupkg |
| 121 | + tagSource: userSpecifiedTag |
| 122 | + tag: $(version) |
| 123 | + isDraft: true |
| 124 | + addChangeLog: false |
| 125 | + releaseNotesSource: inline |
| 126 | + releaseNotesInline: "<!-- TODO: Generate release notes on GitHub! -->" |
| 127 | + - job: validation |
| 128 | + displayName: Manual validation |
| 129 | + pool: |
| 130 | + type: server |
| 131 | + timeoutInMinutes: 1440 |
| 132 | + steps: |
| 133 | + - task: ManualValidation@0 |
| 134 | + displayName: Wait 24 hours for validation |
| 135 | + inputs: |
| 136 | + notifyUsers: $(Build.RequestedForEmail) |
| 137 | + instructions: Please validate the release and then publish it! |
| 138 | + timeoutInMinutes: 1440 |
| 139 | + - job: publish |
| 140 | + dependsOn: validation |
| 141 | + displayName: Publish to PowerShell Gallery |
| 142 | + pool: |
| 143 | + type: release |
| 144 | + templateContext: |
| 145 | + inputs: |
| 146 | + - input: pipelineArtifact |
| 147 | + artifactName: drop_build_main |
| 148 | + steps: |
| 149 | + - task: NuGetCommand@2 |
| 150 | + displayName: Publish module to PowerShell Gallery |
| 151 | + inputs: |
| 152 | + command: push |
| 153 | + packagesToPush: $(Pipeline.Workspace)/PSDesiredStateConfiguration.$(version).nupkg |
| 154 | + nuGetFeedType: external |
| 155 | + publishFeedCredentials: PowerShellGallery |
0 commit comments