@@ -132,11 +132,11 @@ private static async Task<int> CreateReleaseAsync(CreateSubOptions subOptions, I
132
132
133
133
if ( string . IsNullOrEmpty ( subOptions . Milestone ) )
134
134
{
135
- await CreateReleaseFromMilestone ( github , subOptions . RepositoryOwner , subOptions . RepositoryName , subOptions . Milestone , subOptions . TargetCommitish , subOptions . AssetPaths , subOptions . PreRelease , configuration ) ;
135
+ await CreateReleaseFromMilestone ( github , subOptions . RepositoryOwner , subOptions . RepositoryName , subOptions . Milestone , subOptions . TargetCommitish , subOptions . AssetPaths , subOptions . Prerelease , configuration ) ;
136
136
}
137
137
else
138
138
{
139
- await CreateReleaseFromInputFile ( github , subOptions . RepositoryOwner , subOptions . RepositoryName , subOptions . Name , subOptions . InputFilePath , subOptions . TargetCommitish , subOptions . AssetPaths , subOptions . PreRelease , configuration ) ;
139
+ await CreateReleaseFromInputFile ( github , subOptions . RepositoryOwner , subOptions . RepositoryName , subOptions . Name , subOptions . InputFilePath , subOptions . TargetCommitish , subOptions . AssetPaths , subOptions . Prerelease ) ;
140
140
}
141
141
142
142
return 0 ;
@@ -227,46 +227,20 @@ private static async Task<int> ExportReleasesAsync(ExportSubOptions subOptions,
227
227
}
228
228
}
229
229
230
- private static async Task CreateReleaseFromMilestone ( GitHubClient github , string owner , string repository , string milestone , string targetCommitish , IList < string > assets , bool preRelease , Config configuration )
230
+ private static async Task CreateReleaseFromMilestone ( GitHubClient github , string owner , string repository , string milestone , string targetCommitish , IList < string > assets , bool prerelease , Config configuration )
231
231
{
232
232
var releaseNotesBuilder = new ReleaseNotesBuilder ( new DefaultGitHubClient ( github , owner , repository ) , owner , repository , milestone , configuration ) ;
233
233
234
234
var result = await releaseNotesBuilder . BuildReleaseNotes ( ) ;
235
235
236
- var releaseUpdate = new ReleaseUpdate ( milestone )
237
- {
238
- Draft = true ,
239
- Body = result ,
240
- Name = milestone ,
241
- Prerelease = preRelease
242
- } ;
243
-
244
- if ( ! string . IsNullOrEmpty ( targetCommitish ) )
245
- {
246
- releaseUpdate . TargetCommitish = targetCommitish ;
247
- }
236
+ var releaseUpdate = CreateReleaseUpdate ( milestone , result , prerelease , targetCommitish ) ;
248
237
249
238
var release = await github . Release . Create ( owner , repository , releaseUpdate ) ;
250
239
251
- foreach ( var asset in assets )
252
- {
253
- if ( ! File . Exists ( asset ) )
254
- {
255
- continue ;
256
- }
257
-
258
- var upload = new ReleaseAssetUpload
259
- {
260
- FileName = Path . GetFileName ( asset ) ,
261
- ContentType = "application/octet-stream" ,
262
- RawData = File . Open ( asset , FileMode . Open )
263
- } ;
264
-
265
- await github . Release . UploadAsset ( release , upload ) ;
266
- }
240
+ await AddAssets ( github , assets , release ) ;
267
241
}
268
242
269
- private static async Task CreateReleaseFromInputFile ( GitHubClient github , string owner , string repository , string name , string inputFilePath , string targetCommitish , IList < string > assets , bool preRelease , Config configuration )
243
+ private static async Task CreateReleaseFromInputFile ( GitHubClient github , string owner , string repository , string name , string inputFilePath , string targetCommitish , IList < string > assets , bool prerelease )
270
244
{
271
245
if ( ! File . Exists ( inputFilePath ) )
272
246
{
@@ -275,37 +249,11 @@ private static async Task CreateReleaseFromInputFile(GitHubClient github, string
275
249
276
250
var inputFileContents = File . ReadAllText ( inputFilePath ) ;
277
251
278
- var releaseUpdate = new ReleaseUpdate ( name )
279
- {
280
- Draft = true ,
281
- Body = inputFileContents ,
282
- Name = name ,
283
- Prerelease = preRelease
284
- } ;
285
-
286
- if ( ! string . IsNullOrEmpty ( targetCommitish ) )
287
- {
288
- releaseUpdate . TargetCommitish = targetCommitish ;
289
- }
252
+ var releaseUpdate = CreateReleaseUpdate ( name , inputFileContents , prerelease , targetCommitish ) ;
290
253
291
254
var release = await github . Release . Create ( owner , repository , releaseUpdate ) ;
292
255
293
- foreach ( var asset in assets )
294
- {
295
- if ( ! File . Exists ( asset ) )
296
- {
297
- continue ;
298
- }
299
-
300
- var upload = new ReleaseAssetUpload
301
- {
302
- FileName = Path . GetFileName ( asset ) ,
303
- ContentType = "application/octet-stream" ,
304
- RawData = File . Open ( asset , FileMode . Open )
305
- } ;
306
-
307
- await github . Release . UploadAsset ( release , upload ) ;
308
- }
256
+ await AddAssets ( github , assets , release ) ;
309
257
}
310
258
311
259
private static async Task AddAssets ( GitHubClient github , string owner , string repository , string tagName , IList < string > assetPaths )
@@ -378,7 +326,46 @@ private static async Task PublishRelease(GitHubClient github, string owner, stri
378
326
await github . Release . Edit ( owner , repository , release . Id , releaseUpdate ) ;
379
327
}
380
328
381
- [ System . Diagnostics . CodeAnalysis . SuppressMessage ( "Microsoft.Design" , "CA1031:DoNotCatchGeneralExceptionTypes" , Justification = "This is required here" ) ]
329
+ private static async Task AddAssets ( GitHubClient github , IList < string > assets , Release release )
330
+ {
331
+ foreach ( var asset in assets )
332
+ {
333
+ if ( ! File . Exists ( asset ) )
334
+ {
335
+ continue ;
336
+ }
337
+
338
+ var upload = new ReleaseAssetUpload
339
+ {
340
+ FileName = Path . GetFileName ( asset ) ,
341
+ ContentType = "application/octet-stream" ,
342
+ RawData = File . Open ( asset , FileMode . Open )
343
+ } ;
344
+
345
+ await github . Release . UploadAsset ( release , upload ) ;
346
+ }
347
+ }
348
+
349
+ private static ReleaseUpdate CreateReleaseUpdate ( string name , string body , bool prerelease , string targetCommitish )
350
+ {
351
+ var releaseUpdate = new ReleaseUpdate ( name )
352
+ {
353
+ Draft = true ,
354
+ Body = body ,
355
+ Name = name ,
356
+ Prerelease = prerelease
357
+ } ;
358
+
359
+ if ( ! string . IsNullOrEmpty ( targetCommitish ) )
360
+ {
361
+ releaseUpdate . TargetCommitish = targetCommitish ;
362
+ }
363
+
364
+ return releaseUpdate ;
365
+ }
366
+
367
+ [ System . Diagnostics . CodeAnalysis . SuppressMessage ( "Microsoft.Reliability" , "CA2000:Dispose objects before losing scope" , Justification = "Not required." ) ]
368
+ [ System . Diagnostics . CodeAnalysis . SuppressMessage ( "Microsoft.Design" , "CA1031:DoNotCatchGeneralExceptionTypes" , Justification = "This is required here." ) ]
382
369
private static void ConfigureLogging ( string logFilePath )
383
370
{
384
371
var writeActions = new List < Action < string > >
0 commit comments