Skip to content

Commit aefe3d9

Browse files
authored
[Eng] Accept apikey for publish-rmmodules and upgrade node version to 18.20.8 (#27802)
1 parent 5c8065b commit aefe3d9

File tree

4 files changed

+36
-29
lines changed

4 files changed

+36
-29
lines changed

.azure-pipelines/azure-powershell-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ jobs:
9797
- task: NodeTool@0
9898
displayName: Install Autorest
9999
inputs:
100-
versionSpec: '18.20.7'
100+
versionSpec: '18.20.8'
101101
command: custom
102102
verbose: false
103103
customCommand: install autorest@latest
@@ -212,7 +212,7 @@ jobs:
212212
- task: NodeTool@0
213213
displayName: Install autorest
214214
inputs:
215-
versionSpec: '14.17.1'
215+
versionSpec: '18.20.8'
216216
command: custom
217217
verbose: false
218218
customCommand: install autorest@latest

.azure-pipelines/powershell-core.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
- task: NodeTool@0
4848
displayName: Install Autorest
4949
inputs:
50-
versionSpec: '18.20.7'
50+
versionSpec: '18.20.8'
5151
command: custom
5252
verbose: false
5353
customCommand: install autorest@latest
@@ -107,7 +107,7 @@ jobs:
107107
- task: NodeTool@0
108108
displayName: Install autorest
109109
inputs:
110-
versionSpec: '14.17.1'
110+
versionSpec: '18.20.8'
111111
command: custom
112112
verbose: false
113113
customCommand: install autorest@latest

.azure-pipelines/windows-powershell.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
- task: NodeTool@0
4444
displayName: Install Autorest
4545
inputs:
46-
versionSpec: '18.20.7'
46+
versionSpec: '18.20.8'
4747
command: custom
4848
verbose: false
4949
customCommand: install autorest@latest
@@ -103,7 +103,7 @@ jobs:
103103
- task: NodeTool@0
104104
displayName: Install autorest
105105
inputs:
106-
versionSpec: '14.17.1'
106+
versionSpec: '18.20.8'
107107
command: custom
108108
verbose: false
109109
customCommand: install autorest@latest

tools/ModulePublisher.psm1

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -62,32 +62,36 @@ function Get-RepoLocation
6262

6363
function Get-ApiKey
6464
{
65-
param([string]$repoName)
66-
$vaultKey="PSTestGalleryApiKey"
67-
if ($repoName -eq "PSGallery")
68-
{
69-
$vaultKey = "PowerShellGalleryApiKey"
70-
}
65+
[CmdletBinding()]
66+
param(
67+
[string]$repoName
68+
)
7169

72-
$context = (Get-AzContext -ErrorAction Ignore)
70+
$vaultKey="PSTestGalleryApiKey"
71+
if ($repoName -eq "PSGallery")
72+
{
73+
$vaultKey = "PowerShellGalleryApiKey"
74+
}
7375

74-
if ($context -eq $null -or $context.Account -eq $null -or $context.Account.Id -eq $null)
75-
{
76-
Connect-AzAccount -ErrorAction Stop
77-
}
76+
$context = (Get-AzContext -ErrorAction Ignore)
7877

79-
$secret = Get-AzKeyVaultSecret -VaultName kv-azuresdk -Name $vaultKey -ErrorAction Stop
78+
if ($context -eq $null -or $context.Account -eq $null -or $context.Account.Id -eq $null)
79+
{
80+
Connect-AzAccount -ErrorAction Stop
81+
}
8082

81-
if($secret.SecretValueText -eq $null)
82-
{
83-
$secret = Get-AzKeyVaultSecret -VaultName kv-azuresdk -Name $vaultKey -ErrorAction Stop
84-
$secretPlainText = ConvertFrom-SecureString -SecureString $secret.SecretValue -AsPlainText
85-
$secretPlainText
86-
}
87-
else
88-
{
89-
$secret.SecretValueText
90-
}
83+
$secret = Get-AzKeyVaultSecret -VaultName kv-azuresdk -Name $vaultKey -ErrorAction Stop
84+
85+
if($secret.SecretValueText -eq $null)
86+
{
87+
$secret = Get-AzKeyVaultSecret -VaultName kv-azuresdk -Name $vaultKey -ErrorAction Stop
88+
$secretPlainText = ConvertFrom-SecureString -SecureString $secret.SecretValue -AsPlainText
89+
$secretPlainText
90+
}
91+
else
92+
{
93+
$secret.SecretValueText
94+
}
9195
}
9296

9397
function Update-NugetPackage
@@ -206,6 +210,7 @@ function Publish-RMModules
206210
$RepoLocation,
207211

208212
[Parameter(ParameterSetName="ByLocation", Mandatory=$true)]
213+
[Parameter(ParameterSetName="ByLocation", Mandatory=$false)]
209214
[string]
210215
$ApiKey,
211216

@@ -221,7 +226,9 @@ function Publish-RMModules
221226
if ($PSCmdlet.ParameterSetName -eq "ByName")
222227
{
223228
$RepoLocation = (Get-RepoLocation -repoName $RepoName)
224-
$ApiKey = (Get-ApiKey -repoName $RepoName)
229+
if ($null -eq $ApiKey -Or "" -eq $ApiKey) {
230+
$ApiKey = (Get-ApiKey -repoName $RepoName)
231+
}
225232
}
226233
$modules = (Get-ModuleOrder -directory $Path)
227234
foreach ($package in $modules)

0 commit comments

Comments
 (0)