-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
65 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
#!/usr/local/bin/pwsh | ||
param ( | ||
[Parameter(Mandatory = $true)] | ||
[string]$OutputPath, | ||
[int]$PullRequestNumber, | ||
[string]$KeyPath | ||
[Parameter(Mandatory = $true)] | ||
[int]$PullRequestNumber | ||
) | ||
|
||
if (!$Env:PRIVATE_KEY_PATH) { | ||
Write-Error "Environment variable 'PRIVATE_KEY_PATH' is not set." | ||
} | ||
|
||
.github/scripts/pack.ps1 ` | ||
-OutputPath $OutputPath ` | ||
-PullRequestNumber $PullRequestNumber ` | ||
-KeyPath $KeyPath | ||
-KeyPath $Env:PRIVATE_KEY_PATH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,50 @@ | ||
#!/usr/local/bin/pwsh | ||
param ( | ||
[Parameter(Mandatory = $true)] | ||
[string]$OutputPath, | ||
[string]$KeyPath, | ||
[string]$NugetApiKey | ||
[Parameter(Mandatory = $true)] | ||
[ValidateScript({ $_ })] | ||
[string]$CommitSHA | ||
) | ||
|
||
$commitMessage = "$(git log -1 --pretty=%B)" | ||
if (!$Env:PRIVATE_KEY_PATH) { | ||
Write-Error "Environment variable 'PRIVATE_KEY_PATH' is not set." | ||
} | ||
|
||
if (!$Env:NUGET_API_KEY) { | ||
Write-Error "Environment variable 'NUGET_API_KEY' is not set." | ||
} | ||
|
||
$commitMessage = "$(git log $CommitSHA -1 --pretty=%B)" | ||
$pattern = "(?<=Merge pull request #)(\d+)" | ||
if (!($commitMessage -match $pattern)) { | ||
Write-Error "Commit message does not contain a pull request number." | ||
} | ||
$pullRequestNumber = $matches[1] | ||
|
||
Remove-Item -Force -Recurse pack -ErrorAction SilentlyContinue | ||
Remove-Item -Path $OutputPath -Force -Recurse -ErrorAction SilentlyContinue | ||
|
||
$commitSHA = "$(git log -1 --pretty=%H)" | ||
.github/scripts/pack.ps1 ` | ||
-OutputPath $OutputPath ` | ||
-PullRequestNumber $matches[1] ` | ||
-KeyPath $KeyPath ` | ||
-CommitSHA $commitSHA | ||
-PullRequestNumber $pullRequestNumber ` | ||
-KeyPath $Env:PRIVATE_KEY_PATH ` | ||
-CommitSHA $CommitSHA | ||
|
||
$labelsValue = gh pr view $pullRequestNumber --json labels | ConvertFrom-Json -AsHashtable | ||
$labels = $labelsValue | Select-Object -ExpandProperty labels | ForEach-Object { | ||
$_.name | ||
} | ||
$skipNugetUpload = $labels -contains "skip nuget upload" | ||
if ($skipNugetUpload) { | ||
Write-Host "Skipping NuGet upload" | ||
} | ||
|
||
Get-ChildItem -Path $OutputPath -Filter "*.nupkg" | ForEach-Object { | ||
$nupkgs = Get-ChildItem -Path $OutputPath -Filter "*.nupkg" | ForEach-Object { $_.FullName } | ||
$nupkgs = $skipNugetUpload ? @() : $nupkgs | ||
$nupkgs | ForEach-Object { | ||
dotnet nuget push ` | ||
$_ ` | ||
--skip-duplicate ` | ||
--api-key $NugetApiKey ` | ||
--api-key $Env:NUGET_API_KEY ` | ||
--source https://api.nuget.org/v3/index.json | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters