@@ -88,63 +88,19 @@ be placed in the release notes instead.
88
88
#>
89
89
function UpdateModule ([string ]$PathToModule , [string []]$ChangeLogContent )
90
90
{
91
- # Get the content of the service psd1 file
92
- $content = Get-Content $PathToModule - Encoding UTF8
91
+ $releaseNotes = @ ()
93
92
94
- # The size of the new file will be everything in the array we got from
95
- # UpdateServiceChangeLog, except we exclude the last line (which is assumed to be blank)
96
- $size = $content.Length + $ChangeLogContent.Length - 1
97
-
98
- # Create a new object with enough space for the old content plus the new changes made this release
99
- $newContent = New-Object string[] $size
100
-
101
- $buffer = 0
102
-
103
- for ($idx = 0 ; $idx -lt $content.Length ; $idx ++ )
93
+ if ($ChangeLogContent.Length -le 1 )
104
94
{
105
- # Once we reach the release notes section, we need to update the information
106
- if ($content [$idx ] -like " *ReleaseNotes =*" )
107
- {
108
- $end = $content [$idx ].IndexOf(" '" )
109
- $newContent [$idx ] = $content [$idx ].Substring(0 , $end )
110
-
111
- # If there were no changes made this release, set the notes as the common code string
112
- if ($ChangeLogContent.Length -le 1 )
113
- {
114
- $newContent [$idx ] += " 'Updated for common code changes'"
115
- }
116
- # If there were changes made this release, add the changes
117
- else
118
- {
119
- $newContent [$idx ] += " '$ ( $ChangeLogContent [0 ]) "
120
- for ($tempBuffer = 1 ; $tempBuffer -lt $ChangeLogContent.Length - 1 ; $tempBuffer ++ )
121
- {
122
- $newContent [$idx + $tempBuffer ] = $ChangeLogContent [$tempBuffer ]
123
-
124
- # If we are on the last line, add the apostrophe to end the string
125
- if (($tempBuffer + 1 ) -eq ($ChangeLogContent.Length -1 ))
126
- {
127
- $newContent [$idx + $tempBuffer ] += " '"
128
- }
129
- }
130
-
131
- # Update the buffer
132
- $buffer = $ChangeLogContent.Length - 2
133
- }
134
-
135
- }
136
- # For all other lines in the psd1 file, add them to the new content array
137
- else
138
- {
139
- $newContent [$idx + $buffer ] = $content [$idx ]
140
- }
95
+ $releaseNotes += " Updated for common code changes"
96
+ }
97
+ else
98
+ {
99
+ $releaseNotes += $ChangeLogContent
141
100
}
142
101
143
- # Update the service psd1 file to include all of the changes we made
144
- $result = $newContent -join " `r`n "
145
- $tempFile = Get-Item $PathToModule
146
102
147
- [ System.IO.File ]::WriteAllText( $tempFile .FullName , $result , [ Text.Encoding ]::UTF8)
103
+ Update-ModuleManifest - Path $PathToModule - ReleaseNotes $releaseNotes
148
104
}
149
105
150
106
<#
@@ -189,89 +145,7 @@ This function will use the psd1 file to grab the module version.
189
145
#>
190
146
function GetModuleVersion ([string ]$PathToModule )
191
147
{
192
- # Get the content of the psd1 file
193
- $content = Get-Content $PathToModule - Encoding UTF8
194
-
195
- # For each line of the file, check if we have found the module version
196
- for ($idx = 0 ; $idx -lt $content.Length ; $idx ++ )
197
- {
198
- # If we have found the module version, grab the value and return it
199
- if ($content [$idx ] -like " ModuleVersion*" )
200
- {
201
- $start = $content [$idx ].IndexOf(" '" ) + 1
202
-
203
- $end = $content [$idx ].LastIndexOf(" '" )
204
-
205
- $length = $end - $start
206
-
207
- return $content [$idx ].Substring($start , $length )
208
- }
209
- }
210
-
211
- # Throw if we are unable to find the module version
212
- throw " Could not find module version for file $PathToModule "
213
- }
214
-
215
- <#
216
- This function will clear the release notes for a psd1 file.
217
- #>
218
- function ClearReleaseNotes ([string ]$PathToModule )
219
- {
220
- # Get the contents of the psd1 file
221
- $content = Get-Content $PathToModule - Encoding UTF8
222
-
223
- # This will keep track of the size of the current release notes
224
- $length = 0
225
- # This will let us know if we are currently iterating over the release notes
226
- $found = $False
227
-
228
- # For each line of the file, look for the release notes and find the size
229
- for ($idx = 0 ; $idx -lt $content.Length ; $idx ++ )
230
- {
231
- # If we have found the release notes section, switch the variable on
232
- if ($content [$idx ] -like " *ReleaseNotes =*" )
233
- {
234
- $found = $True
235
- }
236
- # If we have found the end of the release notes section, switch the variable off
237
- elseif ($content [$idx ] -like " *End of PSData*" )
238
- {
239
- $found = $false
240
- }
241
- # If we are currently iterating over release notes, increment the size
242
- elseif ($found )
243
- {
244
- $length ++
245
- }
246
- }
247
-
248
- # Determine the size of the file without the release notes
249
- $size = $content.Length - $length + 1
250
-
251
- # Create a new object that will hold the contents of the new psd1 file
252
- $newContent = New-Object string[] $size
253
-
254
- $buffer = 0
255
-
256
- # For each line in the psd1 file, copy it over to the new psd1 file, but
257
- # make sure to skip the release notes
258
- for ($idx = 0 ; $idx -lt $newContent.Length ; $idx ++ )
259
- {
260
- $newContent [$idx ] = $content [$idx + $buffer ]
261
-
262
- # If we have found the release notes, set the buffer so we do not copy
263
- # them over to the new psd1 file
264
- if ($content [$idx ] -like " *ReleaseNotes =*" )
265
- {
266
- $buffer = $length - 1
267
- }
268
- }
269
-
270
- # Update the psd1 file to include all of the changes we made
271
- $result = $newContent -join " `r`n "
272
- $tempFile = Get-Item $PathToModule
273
-
274
- [System.IO.File ]::WriteAllText($tempFile.FullName , $result , [Text.Encoding ]::UTF8)
148
+ return (Test-ModuleManifest - Path $PathToModule ).Version.ToString()
275
149
}
276
150
277
151
<#
@@ -294,8 +168,17 @@ function UpdateARMLogs([string]$PathToServices)
294
168
{
295
169
# Get the service folder
296
170
$Service = Get-Item - Path " $ ( $log.FullName ) \.."
171
+
172
+ $serviceName = $Service.Name
173
+
174
+ if ($serviceName -eq " AzureBackup" ) { $serviceName = " Backup" }
175
+ if ($serviceName -eq " AzureBatch" ) { $serviceName = " Batch" }
176
+
177
+
178
+
179
+
297
180
# Get the psd1 file
298
- $Module = Get-Item - Path " $ ( $Service .FullName ) \* .psd1"
181
+ $Module = Get-Item - Path " $PathToRepo \src\Package\Debug\ResourceManager\AzureResourceManager\AzureRM. $serviceName \AzureRM. $serviceName .psd1"
299
182
300
183
# Get the path to the change log
301
184
$PathToChangeLog = " $ ( $log.FullName ) "
@@ -332,9 +215,6 @@ function UpdateLog([string]$PathToChangeLog, [string]$PathToModule, [string]$Ser
332
215
# Get the module version for ServiceManagement
333
216
$ModuleVersion = GetModuleVersion - PathToModule $module.FullName
334
217
335
- # Clear the release notes for ServiceManagement
336
- ClearReleaseNotes - PathToModule $module.FullName
337
-
338
218
# Update the change log and get the contents of the change log for the current release
339
219
$changeLogContent = UpdateServiceChangeLog - PathToChangeLog $log.FullName - ModuleVersion $ModuleVersion
340
220
@@ -366,18 +246,20 @@ if (!$PathToRepo)
366
246
$PathToRepo = " $PSScriptRoot \.."
367
247
}
368
248
249
+ Import-Module PowerShellGet
250
+
369
251
# Update all of the ResourceManager change logs
370
252
$ResourceManagerResult = UpdateARMLogs - PathToServices $PathToRepo \src\ResourceManager
371
253
372
254
# Update the ServiceManagement change log
373
255
$PathToChangeLog = " $PathToRepo \src\ServiceManagement\Services\Commands.Utilities\ChangeLog.md"
374
- $PathToModule = " $PathToRepo \src\ServiceManagement\Services\Commands.Utilities \Azure.psd1"
256
+ $PathToModule = " $PathToRepo \src\Package\Debug\ServiceManagement\Azure \Azure.psd1"
375
257
376
258
$ServiceManagementResult = UpdateLog - PathToChangeLog $PathToChangeLog - PathToModule $PathToModule - Service " ServiceManagement"
377
259
378
260
# Update the Storage change log
379
261
$PathToChangeLog = " $PathToRepo \src\Storage\ChangeLog.md"
380
- $PathToModule = " $PathToRepo \src\Storage\Azure.Storage.psd1"
262
+ $PathToModule = " $PathToRepo \src\Package\Debug\Storage\Azure. Storage\Azure.Storage.psd1"
381
263
382
264
$StorageResult = UpdateLog - PathToChangeLog $PathToChangeLog - PathToModule $PathToModule - Service " Azure.Storage"
383
265
0 commit comments