@@ -247,7 +247,7 @@ filter New-GitHubRelease
247
247
The OwnerName and RepositoryName will be extracted from here instead of needing to provide
248
248
them individually.
249
249
250
- . PARAMETER TagName
250
+ . PARAMETER Tag
251
251
The name of the tag. The tag will be created around the committish if it doesn't exist
252
252
in the remote, and will need to be synced back to the local repository afterwards.
253
253
@@ -298,7 +298,7 @@ filter New-GitHubRelease
298
298
GitHub.Release
299
299
300
300
. EXAMPLE
301
- New-GitHubRelease -OwnerName microsoft -RepositoryName PowerShellForGitHub -TagName 0.12.0
301
+ New-GitHubRelease -OwnerName microsoft -RepositoryName PowerShellForGitHub -Tag 0.12.0
302
302
303
303
. NOTES
304
304
Requires push access to the repository.
@@ -325,7 +325,7 @@ filter New-GitHubRelease
325
325
[string ] $Uri ,
326
326
327
327
[Parameter (Mandatory )]
328
- [string ] $TagName ,
328
+ [string ] $Tag ,
329
329
330
330
[Alias (' Sha' )]
331
331
[Alias (' BranchName' )]
@@ -363,7 +363,7 @@ filter New-GitHubRelease
363
363
}
364
364
365
365
$hashBody = @ {
366
- ' tag_name' = $TagName
366
+ ' tag_name' = $Tag
367
367
}
368
368
369
369
if ($PSBoundParameters.ContainsKey (' Committish' )) { $hashBody [' target_commitish' ] = $Committish }
@@ -376,14 +376,14 @@ filter New-GitHubRelease
376
376
' UriFragment' = " /repos/$OwnerName /$RepositoryName /releases"
377
377
' Body' = (ConvertTo-Json - InputObject $hashBody )
378
378
' Method' = ' Post'
379
- ' Description' = " Creating release at $TagName "
379
+ ' Description' = " Creating release at $Tag "
380
380
' AccessToken' = $AccessToken
381
381
' TelemetryEventName' = $MyInvocation.MyCommand.Name
382
382
' TelemetryProperties' = $telemetryProperties
383
383
' NoStatus' = (Resolve-ParameterWithDefaultConfigurationValue - Name NoStatus - ConfigValueName DefaultNoStatus)
384
384
}
385
385
386
- if (-not $PSCmdlet.ShouldProcess ($TagName , " Create release for $RepositoryName at tag" ))
386
+ if (-not $PSCmdlet.ShouldProcess ($Tag , " Create release for $RepositoryName at tag" ))
387
387
{
388
388
return
389
389
}
@@ -418,7 +418,7 @@ filter Set-GitHubRelease
418
418
. PARAMETER Release
419
419
The ID of the release to edit.
420
420
421
- . PARAMETER TagName
421
+ . PARAMETER Tag
422
422
The name of the tag.
423
423
424
424
. PARAMETER Committish
@@ -468,7 +468,7 @@ filter Set-GitHubRelease
468
468
GitHub.Release
469
469
470
470
. EXAMPLE
471
- Set-GitHubRelease -OwnerName microsoft -RepositoryName PowerShellForGitHub -TagName 0.12.0 -Body 'Adds core support for Projects'
471
+ Set-GitHubRelease -OwnerName microsoft -RepositoryName PowerShellForGitHub -Tag 0.12.0 -Body 'Adds core support for Projects'
472
472
473
473
. NOTES
474
474
Requires push access to the repository.
@@ -497,7 +497,7 @@ filter Set-GitHubRelease
497
497
[Alias (' ReleaseId' )]
498
498
[int64 ] $Release ,
499
499
500
- [string ] $TagName ,
500
+ [string ] $Tag ,
501
501
502
502
[Alias (' Sha' )]
503
503
[Alias (' BranchName' )]
@@ -527,7 +527,7 @@ filter Set-GitHubRelease
527
527
$telemetryProperties = @ {
528
528
' OwnerName' = (Get-PiiSafeString - PlainText $OwnerName )
529
529
' RepositoryName' = (Get-PiiSafeString - PlainText $RepositoryName )
530
- ' ProvidedTagName ' = ($PSBoundParameters.ContainsKey (' TagName ' ))
530
+ ' ProvidedTag ' = ($PSBoundParameters.ContainsKey (' Tag ' ))
531
531
' ProvidedCommittish' = ($PSBoundParameters.ContainsKey (' Committish' ))
532
532
' ProvidedName' = ($PSBoundParameters.ContainsKey (' Name' ))
533
533
' ProvidedBody' = ($PSBoundParameters.ContainsKey (' Body' ))
@@ -536,7 +536,7 @@ filter Set-GitHubRelease
536
536
}
537
537
538
538
$hashBody = @ {}
539
- if ($PSBoundParameters.ContainsKey (' TagName ' )) { $hashBody [' tag_name' ] = $TagName }
539
+ if ($PSBoundParameters.ContainsKey (' Tag ' )) { $hashBody [' tag_name' ] = $Tag }
540
540
if ($PSBoundParameters.ContainsKey (' Committish' )) { $hashBody [' target_commitish' ] = $Committish }
541
541
if ($PSBoundParameters.ContainsKey (' Name' )) { $hashBody [' name' ] = $Name }
542
542
if ($PSBoundParameters.ContainsKey (' Body' )) { $hashBody [' body' ] = $Body }
@@ -547,7 +547,7 @@ filter Set-GitHubRelease
547
547
' UriFragment' = " /repos/$OwnerName /$RepositoryName /releases/$Release "
548
548
' Body' = (ConvertTo-Json - InputObject $hashBody )
549
549
' Method' = ' Patch'
550
- ' Description' = " Creating release at $TagName "
550
+ ' Description' = " Creating release at $Tag "
551
551
' AccessToken' = $AccessToken
552
552
' TelemetryEventName' = $MyInvocation.MyCommand.Name
553
553
' TelemetryProperties' = $telemetryProperties
@@ -589,6 +589,9 @@ filter Remove-GitHubRelease
589
589
. PARAMETER Release
590
590
The ID of the release to remove.
591
591
592
+ . PARAMETER Force
593
+ If this switch is specified, you will not be prompted for confirmation of command execution.
594
+
592
595
. PARAMETER AccessToken
593
596
If provided, this will be used as the AccessToken for authentication with the
594
597
REST Api. Otherwise, will attempt to use the configured value or will run unauthenticated.
@@ -652,6 +655,8 @@ filter Remove-GitHubRelease
652
655
[Alias (' ReleaseId' )]
653
656
[int64 ] $Release ,
654
657
658
+ [switch ] $Force ,
659
+
655
660
[string ] $AccessToken ,
656
661
657
662
[switch ] $NoStatus
@@ -678,6 +683,11 @@ filter Remove-GitHubRelease
678
683
' NoStatus' = (Resolve-ParameterWithDefaultConfigurationValue - Name NoStatus - ConfigValueName DefaultNoStatus)
679
684
}
680
685
686
+ if ($Force -and (-not $Confirm ))
687
+ {
688
+ $ConfirmPreference = ' None'
689
+ }
690
+
681
691
if (-not $PSCmdlet.ShouldProcess ($Release , " Remove GitHub Release" ))
682
692
{
683
693
return
@@ -890,15 +900,15 @@ filter Get-GitHubReleaseAsset
890
900
if ($PSCmdlet.ParameterSetName -in (' Elements-Download' , ' Uri-Download' ))
891
901
{
892
902
Write-Log - Message " Moving [$ ( $result.FullName ) ] to [$Path ]" - Level Verbose
893
- return (Move-Item - Path $result - Destination $Path - Force:$Force - PassThru)
903
+ return (Move-Item - Path $result - Destination $Path - Force:$Force - ErrorAction Stop - PassThru)
894
904
}
895
905
else
896
906
{
897
907
return ($result | Add-GitHubReleaseAssetAdditionalProperties )
898
908
}
899
909
}
900
910
901
- function New-GitHubReleaseAsset
911
+ filter New-GitHubReleaseAsset
902
912
{
903
913
<#
904
914
. SYNOPSIS
@@ -969,7 +979,16 @@ function New-GitHubReleaseAsset
969
979
GitHub.ReleaseAsset
970
980
971
981
. EXAMPLE
972
- New-GitHubReleaseAsset -OwnerName microsoft -RepositoryName PowerShellForGitHub -TagName 0.12.0
982
+ New-GitHubReleaseAsset -OwnerName microsoft -RepositoryName PowerShellForGitHub -Release 123456 -Path 'c:\foo.zip'
983
+
984
+ Uploads the file located at 'c:\foo.zip' to the 123456 release in microsoft/PowerShellForGitHub
985
+
986
+ . EXAMPLE
987
+ $release = New-GitHubRelease -OwnerName microsoft -RepositoryName PowerShellForGitHub -Tag 'stable'
988
+ $release | New-GitHubReleaseAsset -Path 'c:\bar.txt'
989
+
990
+ Creates a new release tagged as 'stable' and then uploads 'c:\bar.txt' as an asset for
991
+ that release.
973
992
974
993
. NOTES
975
994
GitHub renames asset filenames that have special characters, non-alphanumeric characters,
@@ -1002,12 +1021,7 @@ function New-GitHubReleaseAsset
1002
1021
1003
1022
[Parameter (
1004
1023
Mandatory ,
1005
- ValueFromPipelineByPropertyName ,
1006
- ParameterSetName = ' Elements' )]
1007
- [Parameter (
1008
- Mandatory ,
1009
- ValueFromPipelineByPropertyName ,
1010
- ParameterSetName = ' Uri' )]
1024
+ ValueFromPipelineByPropertyName )]
1011
1025
[Alias (' ReleaseId' )]
1012
1026
[int64 ] $Release ,
1013
1027
@@ -1021,7 +1035,7 @@ function New-GitHubReleaseAsset
1021
1035
Mandatory ,
1022
1036
ValueFromPipeline )]
1023
1037
[ValidateScript (
1024
- {if (Test-Path - Path $_ - PathType Leaf) { $true }
1038
+ {if (Test-Path - Path $_ - PathType Leaf) { $true }
1025
1039
else { throw " $_ does not exist or is inaccessible." }})]
1026
1040
[string ] $Path ,
1027
1041
@@ -1034,80 +1048,72 @@ function New-GitHubReleaseAsset
1034
1048
[switch ] $NoStatus
1035
1049
)
1036
1050
1037
- begin
1038
- {
1039
- Write-InvocationLog
1051
+ Write-InvocationLog
1040
1052
1041
- $telemetryProperties = @ {
1042
- ' ProvidedUploadUrl' = ($PSBoundParameters.ContainsKey (' UploadUrl' ))
1043
- ' ProvidedLabel' = ($PSBoundParameters.ContainsKey (' Label' ))
1044
- ' ProvidedContentType' = ($PSBoundParameters.ContainsKey (' ContentType' ))
1045
- }
1053
+ $telemetryProperties = @ {
1054
+ ' ProvidedUploadUrl' = ($PSBoundParameters.ContainsKey (' UploadUrl' ))
1055
+ ' ProvidedLabel' = ($PSBoundParameters.ContainsKey (' Label' ))
1056
+ ' ProvidedContentType' = ($PSBoundParameters.ContainsKey (' ContentType' ))
1057
+ }
1046
1058
1047
- # If UploadUrl wasn't provided, we'll need to query for it first.
1048
- if ($PSCmdlet.ParameterSetName -in (' Elements' , ' Uri' ))
1049
- {
1050
- $elements = Resolve-RepositoryElements
1051
- $OwnerName = $elements.ownerName
1052
- $RepositoryName = $elements.repositoryName
1053
-
1054
- $telemetryProperties [' OwnerName' ] = (Get-PiiSafeString - PlainText $OwnerName )
1055
- $telemetryProperties [' RepositoryName' ] = (Get-PiiSafeString - PlainText $RepositoryName )
1056
-
1057
- $params = @ {
1058
- ' OwnerName' = $OwnerName
1059
- ' RepositoryName' = $RepositoryName
1060
- ' Release' = $Release
1061
- ' AccessToken' = $AccessToken
1062
- ' NoStatus' = (Resolve-ParameterWithDefaultConfigurationValue - Name NoStatus - ConfigValueName DefaultNoStatus)
1063
- }
1059
+ # If UploadUrl wasn't provided, we'll need to query for it first.
1060
+ if ([String ]::IsNullOrEmpty($UploadUrl ))
1061
+ {
1062
+ $elements = Resolve-RepositoryElements
1063
+ $OwnerName = $elements.ownerName
1064
+ $RepositoryName = $elements.repositoryName
1064
1065
1065
- $releaseInfo = Get-GitHubRelease @params
1066
- $UploadUrl = $releaseInfo.upload_url
1067
- }
1066
+ $telemetryProperties [' OwnerName' ] = (Get-PiiSafeString - PlainText $OwnerName )
1067
+ $telemetryProperties [' RepositoryName' ] = (Get-PiiSafeString - PlainText $RepositoryName )
1068
1068
1069
- # Remove the '{name,label}' from the Url if it's there
1070
- if ($UploadUrl -match ' (.*){' )
1071
- {
1072
- $UploadUrl = $Matches [1 ]
1069
+ $params = @ {
1070
+ ' OwnerName' = $OwnerName
1071
+ ' RepositoryName' = $RepositoryName
1072
+ ' Release' = $Release
1073
+ ' AccessToken' = $AccessToken
1074
+ ' NoStatus' = (Resolve-ParameterWithDefaultConfigurationValue - Name NoStatus - ConfigValueName DefaultNoStatus)
1073
1075
}
1076
+
1077
+ $releaseInfo = Get-GitHubRelease @params
1078
+ $UploadUrl = $releaseInfo.upload_url
1074
1079
}
1075
1080
1076
- process
1081
+ # Remove the '{name,label}' from the Url if it's there
1082
+ if ($UploadUrl -match ' (.*){' )
1077
1083
{
1078
- $Path = Resolve-UnverifiedPath - Path $Path
1079
- $file = Get-Item - Path $Path
1080
- $fileName = $file.Name
1081
- $fileNameEncoded = [Uri ]::EscapeDataString($fileName )
1082
- $queryParams = @ (" name=$fileNameEncoded " )
1084
+ $UploadUrl = $Matches [1 ]
1085
+ }
1083
1086
1084
- if ( $PSBoundParameters .ContainsKey ( ' Label ' ))
1085
- {
1086
- $labelEncoded = [ Uri ]::EscapeDataString( $Label )
1087
- $queryParams += " label= $labelEncoded "
1088
- }
1087
+ $Path = Resolve-UnverifiedPath - Path $Path
1088
+ $file = Get-Item - Path $Path
1089
+ $fileName = $file .Name
1090
+ $fileNameEncoded = [ Uri ]::EscapeDataString( $fileName )
1091
+ $queryParams = @ ( " name= $fileNameEncoded " )
1089
1092
1090
- if (-not $PSCmdlet.ShouldProcess ($Path , " Create new GitHub Release Asset" ))
1091
- {
1092
- return
1093
- }
1093
+ if ($PSBoundParameters.ContainsKey (' Label' ))
1094
+ {
1095
+ $labelEncoded = [Uri ]::EscapeDataString($Label )
1096
+ $queryParams += " label=$labelEncoded "
1097
+ }
1094
1098
1095
- $params = @ {
1096
- ' UriFragment' = $UploadUrl + ' ?' + ($queryParams -join ' &' )
1097
- ' Method' = ' Post'
1098
- ' Description' = " Uploading $fileName as a release asset"
1099
- ' InFile' = $Path
1100
- ' ContentType' = $ContentType
1101
- ' AccessToken' = $AccessToken
1102
- ' TelemetryEventName' = $MyInvocation.MyCommand.Name
1103
- ' TelemetryProperties' = $telemetryProperties
1104
- ' NoStatus' = (Resolve-ParameterWithDefaultConfigurationValue - Name NoStatus - ConfigValueName DefaultNoStatus)
1105
- }
1099
+ if (-not $PSCmdlet.ShouldProcess ($Path , " Create new GitHub Release Asset" ))
1100
+ {
1101
+ return
1102
+ }
1106
1103
1107
- return (Invoke-GHRestMethod @params | Add-GitHubReleaseAssetAdditionalProperties )
1104
+ $params = @ {
1105
+ ' UriFragment' = $UploadUrl + ' ?' + ($queryParams -join ' &' )
1106
+ ' Method' = ' Post'
1107
+ ' Description' = " Uploading release asset: $fileName "
1108
+ ' InFile' = $Path
1109
+ ' ContentType' = $ContentType
1110
+ ' AccessToken' = $AccessToken
1111
+ ' TelemetryEventName' = $MyInvocation.MyCommand.Name
1112
+ ' TelemetryProperties' = $telemetryProperties
1113
+ ' NoStatus' = (Resolve-ParameterWithDefaultConfigurationValue - Name NoStatus - ConfigValueName DefaultNoStatus)
1108
1114
}
1109
1115
1110
- end {}
1116
+ return ( Invoke-GHRestMethod @params | Add-GitHubReleaseAssetAdditionalProperties )
1111
1117
}
1112
1118
1113
1119
filter Set-GitHubReleaseAsset
@@ -1277,6 +1283,9 @@ filter Remove-GitHubReleaseAsset
1277
1283
. PARAMETER Asset
1278
1284
The ID of the asset to remove.
1279
1285
1286
+ . PARAMETER Force
1287
+ If this switch is specified, you will not be prompted for confirmation of command execution.
1288
+
1280
1289
. PARAMETER AccessToken
1281
1290
If provided, this will be used as the AccessToken for authentication with the
1282
1291
REST Api. Otherwise, will attempt to use the configured value or will run unauthenticated.
@@ -1337,6 +1346,8 @@ filter Remove-GitHubReleaseAsset
1337
1346
[Alias (' AssetId' )]
1338
1347
[int64 ] $Asset ,
1339
1348
1349
+ [switch ] $Force ,
1350
+
1340
1351
[string ] $AccessToken ,
1341
1352
1342
1353
[switch ] $NoStatus
@@ -1363,6 +1374,11 @@ filter Remove-GitHubReleaseAsset
1363
1374
' NoStatus' = (Resolve-ParameterWithDefaultConfigurationValue - Name NoStatus - ConfigValueName DefaultNoStatus)
1364
1375
}
1365
1376
1377
+ if ($Force -and (-not $Confirm ))
1378
+ {
1379
+ $ConfirmPreference = ' None'
1380
+ }
1381
+
1366
1382
if (-not $PSCmdlet.ShouldProcess ($Asset , " Delete GitHub Release Asset" ))
1367
1383
{
1368
1384
return
0 commit comments