forked from 51Degrees/pipeline-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish-packages.yml
164 lines (147 loc) · 5.4 KB
/
publish-packages.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
trigger:
- master
- develop
- release/*
variables:
- group: CertificateVariables
# Because we are pulling in a group, we need to define local variables
# using the name/value syntax.
- name: RestoreBuildProjects
value: '**/*.sln'
# Projects to be published as NuGet packages.
# Note the the Web and Web.Framework projects are published as a single package
# using a nuspec file rather than directly from the project files. Hence they
# are excluded here.
- name: PublishProjects
value: '**/*.csproj;!**/*[Tt]ests/**/*.csproj;!**/*[Ee]xamples/**/*.csproj;!**/FiftyOne.Pipeline.Web.csproj;!**/FiftyOne.Pipeline.Web.Framework.csproj'
# Access token for the git repository. Used by the git tag task.
- name: system_accesstoken
value: $(System.AccessToken)
pool:
vmImage: 'windows-2019'
steps:
- bash: |
git lfs install
ls
git config --global --add filter.lfs.required true
git config --global --add filter.lfs.smudge "git-lfs smudge -- %f"
git config --global --add filter.lfs.process "git-lfs filter-process"
git config --global --add filter.lfs.clean "git-lfs clean -- %f"
displayName: 'Configure git lfs'
# The lines below are needed to allow the pipeline access to the
# OAuth access token that controls write access to the git repository.
# (Required for GitTag task)
- checkout: self
lfs: true
submodules: recursive
persistCredentials: true
# Useful snippets for debugging.
# List all contents of a directory:
#- script: |
# ls -d $(System.ArtifactsDirectory)/*
# Use a script to set the BuildConfiguration variable.
# If building from master or a release branch then build
# the Release configuration. Otherwise, build the Debug configuration.
- script: |
echo Current branch is "%BUILD_SOURCEBRANCH%"
echo %BUILD_SOURCEBRANCH% |findstr /b "refs/heads/release/*" > nul && (
set ISRELEASEBRANCH=true
) || (
set ISRELEASEBRANCH=false
)
if "%BUILD_SOURCEBRANCHNAME%" == "master" (
SET BUILD_CONFIG=Release
) else if %ISRELEASEBRANCH% == true (
SET BUILD_CONFIG=Release
) else (
SET BUILD_CONFIG=Debug
)
echo ##vso[task.setvariable variable=BuildConfiguration]%BUILD_CONFIG%
echo BuildConfiguration set to '%BUILD_CONFIG%'
displayName: 'Determine Build Configuration'
- task: NuGetToolInstaller@1
displayName: 'Use NuGet 5.3.1'
inputs:
versionSpec: 5.3.1
- task: NuGetCommand@2
displayName: 'NuGet restore'
inputs:
command: 'restore'
restoreSolution: '$(RestoreBuildProjects)'
feedsToUse: 'select'
vstsFeed: 'd2431f86-c1e6-4d8b-8d27-311cf3614847'
- task: gittools.gitversion.gitversion-task.GitVersion@4
displayName: 'Determine Version Number'
# Give this task a name so we can use the variables it sets later.
name: GitVersion
inputs:
preferBundledVersion: false
- task: DownloadBuildArtifacts@0
displayName: 'Download Build Artifacts'
inputs:
downloadType: specific
itemPattern: '**/*'
downloadPath: '$(build.sourcesdirectory)/'
- task: VSBuild@1
displayName: 'Build solutions Any CPU'
inputs:
solution: '$(RestoreBuildProjects)'
vsVersion: '15.0'
platform: 'Any CPU'
configuration: '$(BuildConfiguration)'
clean: true
msbuildArchitecture: 'x86'
# Index and publish symbol file to allow debugging.
- task: PublishSymbols@2
displayName: 'Publish Symbols'
inputs:
SearchPattern: '**/bin/**/*.pdb'
SymbolServerType: 'TeamServices'
SymbolsVersion: '$(GitVersion.NuGetVersion)'
# The nuget package version uses the BUILD_BUILDNUMER environment variable.
# This has been set by the GitVersion task above.
- task: DotNetCoreCLI@2
displayName: 'Build NuGet Package'
inputs:
command: 'pack'
packagesToPack: '$(PublishProjects)'
versioningScheme: 'byEnvVar'
versionEnvVar: 'BUILD_BUILDNUMBER'
# The Web and Web.Framework projects are combined into a single NuGet package.
# This requires the use of a nuspec file and the NuGet task.
- task: NuGetCommand@2
displayName: 'NuGet pack Pipeline.Web'
inputs:
command: 'pack'
packagesToPack: '**/FiftyOne.Pipeline.Web.nuspec'
versioningScheme: 'byEnvVar'
versionEnvVar: 'BUILD_BUILDNUMBER'
buildProperties: 'config=$(BuildConfiguration)'
# The secure file to download will be stored in the
# Pipelines/Library/SecureFiles section in Azure DevOps.
- task: DownloadSecureFile@1
displayName: 'Download Code Signing Certificate'
name: CodeSigningCert
inputs:
secureFile: ' 51Degrees.mobi Code Signing Certificate.pfx'
# Sign the Nuget package with the file downloaded previously.
# The password is stored in the Pipelines/Library/VariableGroups
# section in Azure DevOps.
- task: NuGetCommand@2
displayName: 'Sign NuGet Package'
inputs:
command: custom
arguments: 'sign $(System.ArtifactsDirectory)\*.nupkg -CertificatePath "$(CodeSigningCert.secureFilePath)" -CertificatePassword $(CodeSigningCertPassword) -Timestamper http://timestamp.digicert.com'
# Add a tag to the git repository with the version number of
# the package that has just been published
- task: ATP.ATP-GitTag.GitTag.GitTag@5
displayName: 'Tag Repo With Version Number'
inputs:
tagUser: 'Azure DevOps'
tagEmail: '[email protected]'
condition: succeeded()
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
condition: succeededOrFailed()