|
| 1 | +trigger: |
| 2 | + branches: |
| 3 | + include: ["master", "develop", "release*", "refs/tags/*" ] |
| 4 | + paths: |
| 5 | + exclude: [ "doc", "*.md", ".gitignore" ] |
| 6 | + |
| 7 | +pr: |
| 8 | + branches: |
| 9 | + include: ["master", "develop", "release*"] |
| 10 | + autoCancel: true |
| 11 | + |
| 12 | +# add nf-tools repo to resources (for Azure Pipelines templates) |
| 13 | +resources: |
| 14 | + repositories: |
| 15 | + - repository: templates |
| 16 | + type: github |
| 17 | + name: nanoframework/nf-tools |
| 18 | + endpoint: nanoframework |
| 19 | + |
| 20 | +jobs: |
| 21 | + |
| 22 | +############################## |
| 23 | +- job: Get_Build_Options |
| 24 | + pool: |
| 25 | + vmImage: 'VS2017-Win2016' |
| 26 | + |
| 27 | + steps: |
| 28 | + - checkout: self |
| 29 | + |
| 30 | +# build tool |
| 31 | +- job: Build_tool |
| 32 | + |
| 33 | + pool: |
| 34 | + vmImage: 'VS2017-Win2016' |
| 35 | + |
| 36 | + variables: |
| 37 | + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true |
| 38 | + buildPlatform: 'Any CPU' |
| 39 | + buildConfiguration: 'Release' |
| 40 | + solution: 'source\nanoFirmwareFlasher.sln' |
| 41 | + |
| 42 | + steps: |
| 43 | + |
| 44 | + # need this here in order to persist GitHub credentials |
| 45 | + - checkout: self |
| 46 | + persistCredentials: true |
| 47 | + |
| 48 | + - script: | |
| 49 | + git config --global user.email "[email protected]" |
| 50 | + git config --global user.name "nfbot" |
| 51 | + displayName: Setup git identity |
| 52 | +
|
| 53 | + - task: NuGetToolInstaller@0 |
| 54 | + inputs: |
| 55 | + versionSpec: '4.9.3' |
| 56 | + displayName: 'Install specifc version of NuGet' |
| 57 | + |
| 58 | + - task: DotNetCoreInstaller@0 |
| 59 | + inputs: |
| 60 | + packageType: sdk |
| 61 | + version: 2.1.500 |
| 62 | + displayName: Install .NET Core SDK |
| 63 | + |
| 64 | + - task: DotNetCoreCLI@2 |
| 65 | + inputs: |
| 66 | + command: restore |
| 67 | + verbosityRestore: minimal # detailed, normal, minimal |
| 68 | + projects: source\nanoFirmwareFlasher.sln |
| 69 | + feedsToUse: config |
| 70 | + nugetConfigPath: source/NuGet.Config |
| 71 | + workingDirectory: source |
| 72 | + displayName: Restore NuGet packages |
| 73 | + |
| 74 | + - script: dotnet build -c $(BuildConfiguration) /p:PublicRelease=true --no-restore /t:build,pack" |
| 75 | + workingDirectory: source |
| 76 | + displayName: Build NuGet package |
| 77 | + |
| 78 | + - script: dotnet build -c $(BuildConfiguration) /p:PublicRelease=true /p:PackGlobalTool=true --no-restore /t:build,pack" |
| 79 | + workingDirectory: source |
| 80 | + displayName: Build .NET Core Tool NuGet package |
| 81 | + |
| 82 | + - task: PowerShell@2 |
| 83 | + inputs: |
| 84 | + targetType: 'inline' |
| 85 | + script: | |
| 86 | + $MyNuGetVersion = $env:NBGV_NuGetPackageVersion -replace "\-g$env:NBGV_GitCommitIdShort", "" |
| 87 | +
|
| 88 | + # replace preview with alpha if this is a PR build |
| 89 | + if($env:Build_Reason -eq 'PullRequest') |
| 90 | + { |
| 91 | + $MyNuGetVersion = $MyNuGetVersion -replace "preview", "alpha" |
| 92 | + } |
| 93 | +
|
| 94 | + Write-Host "NuGet build number is $MyNuGetVersion" |
| 95 | +
|
| 96 | + Write-Host "$("##vso[task.setvariable variable=MY_NUGET_VERSION]")$MyNuGetVersion" |
| 97 | + condition: succeeded() |
| 98 | + displayName: Get NuGet build number |
| 99 | + |
| 100 | + # update could build number (only possible if this is not a PR from a fork) |
| 101 | + - task: PowerShell@2 |
| 102 | + inputs: |
| 103 | + targetType: 'inline' |
| 104 | + script: Write-Host "$("##vso[build.updatebuildnumber]")$env:NBGV_NuGetPackageVersion" |
| 105 | + condition: and( succeeded(), ne(variables['system.pullrequest.isfork'], true) ) |
| 106 | + displayName: Update cloud build number |
| 107 | + |
| 108 | + - powershell: | |
| 109 | + # get subject and commit message for commit |
| 110 | + $commitMessage = git log --format='%B' -1 |
| 111 | +
|
| 112 | + # need to flatten message by removing new lines |
| 113 | + $commitMessage = $commitMessage -replace "`r`n", " " |
| 114 | +
|
| 115 | + if($commitMessage -like "***PUBLISH_RELEASE***") |
| 116 | + { |
| 117 | + # set variable |
| 118 | + Write-Host "$("##vso[task.setvariable variable=RELEASE_DRAFT]")false" |
| 119 | + Write-Host "Release draft: FALSE" |
| 120 | + } |
| 121 | + else |
| 122 | + { |
| 123 | + # set variable |
| 124 | + Write-Host "$("##vso[task.setvariable variable=RELEASE_DRAFT]")true" |
| 125 | + Write-Host "Release draft: TRUE" |
| 126 | + } |
| 127 | +
|
| 128 | + displayName: set release draft var |
| 129 | +
|
| 130 | + - task: CopyFiles@1 |
| 131 | + inputs: |
| 132 | + sourceFolder: $(Build.SourcesDirectory) |
| 133 | + Contents: | |
| 134 | + **\*.nupkg |
| 135 | + TargetFolder: '$(Build.ArtifactStagingDirectory)' |
| 136 | + flattenFolders: true |
| 137 | + condition: succeeded() |
| 138 | + displayName: Collecting deployable artifacts |
| 139 | + |
| 140 | + # publish artifacts (only possible if this is not a PR originated on a fork) |
| 141 | + - task: PublishBuildArtifacts@1 |
| 142 | + inputs: |
| 143 | + PathtoPublish: '$(Build.ArtifactStagingDirectory)' |
| 144 | + ArtifactName: deployables |
| 145 | + ArtifactType: Container |
| 146 | + condition: and( succeeded(), ne(variables['system.pullrequest.isfork'], true) ) |
| 147 | + displayName: Publish deployables artifacts |
| 148 | + |
| 149 | + # push NuGet packages to AzureArtifacts feed (always happens except on PR builds) |
| 150 | + - task: NuGetCommand@2 |
| 151 | + inputs: |
| 152 | + command: push |
| 153 | + nuGetFeedType: external |
| 154 | + packagesToPush: '$(Build.ArtifactStagingDirectory)/*.nupkg' |
| 155 | + publishFeedCredentials: 'AzureArtifacts' |
| 156 | + condition: succeeded() |
| 157 | + continueOnError: true |
| 158 | + displayName: Push NuGet packages to AzureArtifacts |
| 159 | + |
| 160 | + # push NuGet class lib package to NuGet (happens on tag builds for any branch) |
| 161 | + - task: NuGetCommand@2 |
| 162 | + inputs: |
| 163 | + command: push |
| 164 | + nuGetFeedType: external |
| 165 | + allowPackageConflicts: true |
| 166 | + packagesToPush: '$(Build.ArtifactStagingDirectory)/*.nupkg' |
| 167 | + publishFeedCredentials: 'NuGet' |
| 168 | + condition: and( succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v') ) |
| 169 | + continueOnError: true |
| 170 | + displayName: Push NuGet packages to NuGet |
| 171 | + |
| 172 | + # create or update GitHub release |
| 173 | + - task: GitHubReleasePublish@1 |
| 174 | + inputs: |
| 175 | + githubEndpoint: 'nanoFramework' |
| 176 | + githubOwner: 'nanoframework' |
| 177 | + githubRepositoryName: 'nanoFirmwareFlasher ' |
| 178 | + githubTag: v$(MY_NUGET_VERSION) |
| 179 | + githubReleaseTitle: 'nano firmware flasher v$(MY_NUGET_VERSION)' |
| 180 | + githubReleaseNotes: 'add description here' |
| 181 | + githubTargetCommitsh: $(Build.SourceVersion) |
| 182 | + githubReleaseDraft: $(RELEASE_DRAFT) |
| 183 | + githubReleasePrerelease: true |
| 184 | + githubReuseDraftOnly: true |
| 185 | + githubReuseRelease: true |
| 186 | + githubEditRelease: true |
| 187 | + githubDeleteEmptyTag: true |
| 188 | + githubReleaseAsset: '$(Build.ArtifactStagingDirectory)/*.nupkg' |
| 189 | + condition: and( succeeded(), not( startsWith(variables['Build.SourceBranch'], 'refs/pull') ), not( startsWith(variables['Build.SourceBranch'], 'refs/tags/v') ) ) |
| 190 | + displayName: Create/Update GitHub release |
| 191 | + |
| 192 | + # create or update GitHub release ON tags from release or master branches |
| 193 | + - task: GitHubReleasePublish@1 |
| 194 | + inputs: |
| 195 | + githubEndpoint: 'nanoFramework' |
| 196 | + githubOwner: 'nanoframework' |
| 197 | + githubRepositoryName: 'nanoFirmwareFlasher ' |
| 198 | + githubTag: v$(MY_NUGET_VERSION) |
| 199 | + githubReleaseTitle: 'nano firmware flasher v$(MY_NUGET_VERSION)' |
| 200 | + githubReleaseNotes: 'add description here' |
| 201 | + githubTargetCommitsh: $(Build.SourceVersion) |
| 202 | + githubReleaseDraft: $(RELEASE_DRAFT) |
| 203 | + githubReleasePrerelease: true |
| 204 | + githubReuseDraftOnly: false |
| 205 | + githubReuseRelease: true |
| 206 | + githubEditRelease: true |
| 207 | + githubDeleteEmptyTag: true |
| 208 | + githubReleaseAsset: '$(Build.ArtifactStagingDirectory)/*.nupkg' |
| 209 | + condition: and( succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), contains(variables['Build.SourceBranch'], 'preview') ) |
| 210 | + displayName: Create/Update GitHub PREVIEW release |
| 211 | + |
| 212 | + # create or update GitHub release ON tags from release or master branches |
| 213 | + - task: GitHubReleasePublish@1 |
| 214 | + inputs: |
| 215 | + githubEndpoint: 'nanoFramework' |
| 216 | + githubOwner: 'nanoframework' |
| 217 | + githubRepositoryName: 'nanoFirmwareFlasher ' |
| 218 | + githubTag: v$(MY_NUGET_VERSION) |
| 219 | + githubReleaseTitle: 'nano firmware flasher v$(MY_NUGET_VERSION)' |
| 220 | + githubReleaseNotes: 'add description here' |
| 221 | + githubTargetCommitsh: $(Build.SourceVersion) |
| 222 | + githubReleaseDraft: false |
| 223 | + githubReleasePrerelease: false |
| 224 | + githubReuseDraftOnly: false |
| 225 | + githubReuseRelease: false |
| 226 | + githubEditRelease: false |
| 227 | + githubDeleteEmptyTag: true |
| 228 | + githubReleaseAsset: '$(Build.ArtifactStagingDirectory)/$(nugetPackageName).$(MY_NUGET_VERSION).nupkg' |
| 229 | + condition: and( succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), not(contains(variables['Build.SourceBranch'], 'preview') ) ) |
| 230 | + displayName: Create/Update GitHub stable release |
0 commit comments