Skip to content

Commit 0502f38

Browse files
authored
🔧 ci: Split into stages (#1176)
Split build into stages. Restrict nuget push to master branch.
1 parent 3a763d7 commit 0502f38

File tree

1 file changed

+108
-81
lines changed

1 file changed

+108
-81
lines changed

azure-pipelines.yml

Lines changed: 108 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -19,84 +19,111 @@ pool:
1919
variables:
2020
- group: common
2121

22-
steps:
23-
- checkout: self
24-
fetchDepth: 1
25-
clean: false
26-
lfs: true
27-
submodules: false
28-
fetchTags: false
29-
30-
- task: InstallNanoMSBuildComponents@1
31-
displayName: Install .NET nanoFramework MSBuild components
32-
33-
- task: PowerShell@2
34-
displayName: 'Build, test, pack'
35-
inputs:
36-
filePath: 'Build/build.ps1'
37-
arguments: '-IncludeNanoFramework'
38-
failOnStderr: true
39-
showWarnings: true
40-
pwsh: true
41-
workingDirectory: '$(Build.SourcesDirectory)'
42-
43-
- task: PowerShell@2
44-
displayName: Upload to codecov.io
45-
env:
46-
CODECOV_TOKEN: $(CODECOV_TOKEN)
47-
inputs:
48-
targetType: 'inline'
49-
script: |
50-
Write-Host -Foreground Green "Downloading codecov binaries..."
51-
52-
Invoke-WebRequest -Uri https://uploader.codecov.io/verification.gpg -OutFile codecov.asc
53-
gpg.exe --import codecov.asc
54-
55-
Invoke-WebRequest -Uri https://uploader.codecov.io/latest/windows/codecov.exe -Outfile codecov.exe
56-
Invoke-WebRequest -Uri https://uploader.codecov.io/latest/windows/codecov.exe.SHA256SUM -Outfile codecov.exe.SHA256SUM
57-
Invoke-WebRequest -Uri https://uploader.codecov.io/latest/windows/codecov.exe.SHA256SUM.sig -Outfile codecov.exe.SHA256SUM.sig
58-
59-
gpg.exe --verify codecov.exe.SHA256SUM.sig codecov.exe.SHA256SUM
60-
If ($(Compare-Object -ReferenceObject $(($(certUtil -hashfile codecov.exe SHA256)[1], "codecov.exe") -join " ") -DifferenceObject $(Get-Content codecov.exe.SHA256SUM)).length -eq 0) { echo "SHASUM verified" } Else {exit 1}
61-
62-
Write-Host -Foreground Green "Uploading to codecov..."
63-
64-
.\codecov.exe --dir "Artifacts/Coverage" -t "$env:CODECOV_TOKEN" --build "$(Build.BuildNumber)"
65-
66-
Write-Host -Foreground Green "✅ Uploaded to codecov."
67-
pwsh: true
68-
69-
- publish: $(Build.SourcesDirectory)/Artifacts
70-
displayName: 'Publish Artifacts'
71-
artifact: 'Artifacts'
72-
73-
- task: CopyFiles@2
74-
displayName: Copy nugets to staging
75-
inputs:
76-
SourceFolder: '$(Build.SourcesDirectory)/Artifacts'
77-
Contents: |
78-
**/*.nupkg
79-
**/*.snupkg
80-
TargetFolder: '$(Build.ArtifactStagingDirectory)'
81-
flattenFolders: true
82-
preserveTimestamp: true
83-
retryCount: '3'
84-
ignoreMakeDirErrors: true
85-
86-
- task: Bash@3
87-
displayName: 'Push to nuget.org'
88-
env:
89-
NUGET_ORG_APIKEY: '$(NUGET_ORG_APIKEY)'
90-
inputs:
91-
targetType: 'inline'
92-
script: 'dotnet nuget push "*.nupkg" --skip-duplicate --api-key $NUGET_ORG_APIKEY --source https://api.nuget.org/v3/index.json'
93-
workingDirectory: '$(Build.ArtifactStagingDirectory)'
94-
95-
- task: NuGetCommand@2
96-
displayName: Push to internal NuGet feed
97-
inputs:
98-
command: 'push'
99-
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg'
100-
nuGetFeedType: 'internal'
101-
publishVstsFeed: 'fee4c64f-3e49-4618-9ea4-5a3167257c37/989275f4-a952-4abd-ae82-2e7a0cb97b9b'
102-
allowPackageConflicts: true
22+
stages:
23+
- stage: Build
24+
displayName: Build & test
25+
jobs:
26+
- job: Build
27+
displayName: Build & test
28+
steps:
29+
- checkout: self
30+
fetchDepth: 1
31+
clean: false
32+
lfs: true
33+
submodules: false
34+
fetchTags: false
35+
36+
- task: InstallNanoMSBuildComponents@1
37+
displayName: Install .NET nanoFramework MSBuild components
38+
39+
- task: PowerShell@2
40+
displayName: 'Build, test, pack'
41+
inputs:
42+
filePath: 'Build/build.ps1'
43+
arguments: '-IncludeNanoFramework'
44+
failOnStderr: true
45+
showWarnings: true
46+
pwsh: true
47+
workingDirectory: '$(Build.SourcesDirectory)'
48+
49+
- task: PowerShell@2
50+
displayName: Upload to codecov.io
51+
env:
52+
CODECOV_TOKEN: $(CODECOV_TOKEN)
53+
inputs:
54+
targetType: 'inline'
55+
script: |
56+
Write-Host -Foreground Green "Downloading codecov binaries..."
57+
58+
Invoke-WebRequest -Uri https://uploader.codecov.io/verification.gpg -OutFile codecov.asc
59+
gpg.exe --import codecov.asc
60+
61+
Invoke-WebRequest -Uri https://uploader.codecov.io/latest/windows/codecov.exe -Outfile codecov.exe
62+
Invoke-WebRequest -Uri https://uploader.codecov.io/latest/windows/codecov.exe.SHA256SUM -Outfile codecov.exe.SHA256SUM
63+
Invoke-WebRequest -Uri https://uploader.codecov.io/latest/windows/codecov.exe.SHA256SUM.sig -Outfile codecov.exe.SHA256SUM.sig
64+
65+
gpg.exe --verify codecov.exe.SHA256SUM.sig codecov.exe.SHA256SUM
66+
If ($(Compare-Object -ReferenceObject $(($(certUtil -hashfile codecov.exe SHA256)[1], "codecov.exe") -join " ") -DifferenceObject $(Get-Content codecov.exe.SHA256SUM)).length -eq 0) { echo "SHASUM verified" } Else {exit 1}
67+
68+
Write-Host -Foreground Green "Uploading to codecov..."
69+
70+
.\codecov.exe --dir "Artifacts/Coverage" -t "$env:CODECOV_TOKEN" --build "$(Build.BuildNumber)"
71+
72+
Write-Host -Foreground Green "✅ Uploaded to codecov."
73+
pwsh: true
74+
75+
- publish: $(Build.SourcesDirectory)/Artifacts
76+
displayName: 'Publish Artifacts'
77+
artifact: 'Artifacts'
78+
79+
- task: CopyFiles@2
80+
displayName: Copy nugets to staging
81+
inputs:
82+
SourceFolder: '$(Build.SourcesDirectory)/Artifacts'
83+
Contents: |
84+
**/*.nupkg
85+
**/*.snupkg
86+
TargetFolder: '$(Build.ArtifactStagingDirectory)'
87+
flattenFolders: true
88+
preserveTimestamp: true
89+
retryCount: '3'
90+
ignoreMakeDirErrors: true
91+
92+
- task: PublishPipelineArtifact@1
93+
displayName: Upload nugets to pipeline
94+
inputs:
95+
targetPath: '$(Build.ArtifactStagingDirectory)'
96+
artifact: 'nugets'
97+
publishLocation: 'pipeline'
98+
99+
- stage: Publish
100+
dependsOn: Build
101+
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
102+
jobs:
103+
- job: Publish
104+
displayName: Publish nugets
105+
steps:
106+
- task: DownloadPipelineArtifact@2
107+
displayName: Download nugets from pipeline
108+
inputs:
109+
buildType: 'current'
110+
artifactName: 'nugets'
111+
targetPath: '$(Build.ArtifactStagingDirectory)'
112+
113+
- task: Bash@3
114+
displayName: 'Push to nuget.org'
115+
env:
116+
NUGET_ORG_APIKEY: '$(NUGET_ORG_APIKEY)'
117+
inputs:
118+
targetType: 'inline'
119+
script: 'dotnet nuget push "*.nupkg" --skip-duplicate --api-key $NUGET_ORG_APIKEY --source https://api.nuget.org/v3/index.json'
120+
workingDirectory: '$(Build.ArtifactStagingDirectory)'
121+
122+
- task: NuGetCommand@2
123+
displayName: Push to internal NuGet feed
124+
inputs:
125+
command: 'push'
126+
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg'
127+
nuGetFeedType: 'internal'
128+
publishVstsFeed: 'fee4c64f-3e49-4618-9ea4-5a3167257c37/989275f4-a952-4abd-ae82-2e7a0cb97b9b'
129+
allowPackageConflicts: true

0 commit comments

Comments
 (0)