forked from Azure/azure-functions-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
141 lines (116 loc) · 3.91 KB
/
azure-pipelines.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
name: 2.1.$(devops_buildNumber)
pr:
branches:
include:
- master
- dev
- v3.x
trigger:
branches:
include:
- dev
- master
pool:
vmImage: 'windows-latest'
variables:
devops_buildNumber: $[counter(format(''), 1500)]
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- task: OneLocBuild@2
enabled: true
inputs:
locProj: 'Build\Localize\LocProject.json'
outDir: '$(Build.Repository.LocalPath)'
packageSourceAuth: 'patAuth'
patVariable: '$(ONELOCBUILD)'
continueOnError: true
- task: CopyFiles@2
enabled: true
displayName: 'Copy Loc files to publish directories'
inputs:
SourceFolder: $(System.DefaultWorkingDirectory)/loc
TargetFolder: $(Build.ArtifactStagingDirectory)
- task: PublishBuildArtifacts@1
enabled: true
displayName: 'Publish Artifact: loc'
inputs:
ArtifactName: 'loc'
- task: Npm@1
inputs:
command: 'install'
workingDir: '.\Build'
- task: Gulp@1
inputs:
buildNumber: $(devops_buildNumber)
gulpFile: '.\Build\gulpfile.js'
targets: 'build-all'
enableCodeCoverage: false
- task: CopyFiles@2
inputs:
SourceFolder: '$(Build.Repository.LocalPath)\bin\VS'
Contents: '*.nupkg'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
CleanTargetFolder: true
- task: CopyFiles@2
inputs:
SourceFolder: '$(Build.Repository.LocalPath)\bin'
Contents: '*.zip'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
CleanTargetFolder: false
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
function GenerateIndexJson($ctx, $templateVersion, $fileRelativePath, $rootPath)
{
$filePath = Join-Path -Path $rootPath -ChildPath $fileRelativePath
$json = @"
{
"version": "$templateVersion",
"commitId" : "$(Build.SourceVersion)"
}
"@
Write-Host $filePath
New-Item -Path $filePath -Force
$json | Out-File -FilePath $filePath -Encoding ascii
$blobName = "ExtensionBundleTemplates\build\" + $fileRelativePath
Set-AzureStorageBlobContent -Container "public" -File $filePath -Blob $blobName -Context $ctx -Force
}
$rootPath = $pwd
# Storage Context
$ctx = New-AzureStorageContext -StorageAccountName "$(ACCOUNT_NAME)" -SasToken "$(ACCOUNT_KEY)"
$files= Get-ChildItem -Recurse -Path "$(System.ArtifactsDirectory)"
foreach($file in $files)
{
$fileName = $file.FullName.ToLower();
if ($fileName.Endswith(".zip") -and !$fileName.Contains("bundle"))
{
$fileFullName = $file.FullName
$blobName = "TemplatesApi\" + $file.Name
Write-Host "Uploading file:$fileFullName"
Set-AzureStorageBlobContent -Container "public" -File $fileFullName -Blob $blobName -Context $ctx
}
if ($fileName.Endswith(".zip") -and $fileName.Contains("bundle"))
{
$fileFullName = $file.FullName
$blobName = "ExtensionBundleTemplates\" + $file.Name
Write-Host "Uploading file:$fileFullName"
Set-AzureStorageBlobContent -Container "public" -File $fileFullName -Blob $blobName -Context $ctx
# upload version.file
$name = $file.Name
$bundleIdLength = $name.IndexOf(".Templates.") + 10
$bundleId = $name.Substring(0,$bundleIdLength)
$path = $bundleId + "\latest\version.json"
$templateVersion = $name.Substring($bundleIdLength+1, 8)
GenerateIndexJson $ctx $templateVersion $path $rootPath
}
}
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'