Skip to content

Commit ba609d5

Browse files
Prep build for publish
1 parent 445670f commit ba609d5

File tree

4 files changed

+26
-7
lines changed

4 files changed

+26
-7
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
run: $PSVersionTable
3232
- uses: actions/checkout@v1
3333
- name: Test and Build
34-
run: ./build.ps1 -Force
34+
run: ./build.ps1 -Force -Configuration Release
3535
- uses: actions/upload-artifact@v1
3636
if: matrix.os == 'windows-latest'
3737
with:

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@v1
2323
- name: Test and Build
24-
run: ./build.ps1 -Force -Publish
24+
run: ./build.ps1 -Force -Publish -Configuration Release
2525
env:
2626
GALLERY_API_KEY: ${{ secrets.GALLERY_API_KEY }}
2727
- name: Upload Test Results

ClassExplorer.build.ps1

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,20 @@ task DoPublish {
204204
throw 'Configuration must not be Debug to publish!'
205205
}
206206

207-
if (-not (Test-Path $env:USERPROFILE\.PSGallery\apikey.xml)) {
207+
if ($env:GALLERY_API_KEY) {
208+
$apiKey = $env:GALLERY_API_KEY
209+
} else {
210+
$userProfile = [Environment]::GetFolderPath([Environment+SpecialFolder]::UserProfile)
211+
if (Test-Path $userProfile/.PSGallery/apikey.xml) {
212+
$apiKey = (Import-Clixml $userProfile/.PSGallery/apikey.xml).GetNetworkCredential().Password
213+
}
214+
}
215+
216+
if (-not $apiKey) {
208217
throw 'Could not find PSGallery API key!'
209218
}
210219

211-
$apiKey = (Import-Clixml $env:USERPROFILE\.PSGallery\apikey.xml).GetNetworkCredential().Password
212-
Publish-Module -Name $Folders.Release -NuGetApiKey $apiKey -Confirm
220+
Publish-Module -Name $Folders.Release -NuGetApiKey $apiKey -Force:$Force.IsPresent
213221
}
214222

215223
task Build -Jobs AssertDevDependencies, Clean, BuildDll, CopyToRelease, BuildDocs

build.ps1

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
[CmdletBinding()]
22
param(
3-
[switch] $Force
3+
[ValidateSet('Debug', 'Release')]
4+
[string] $Configuration = 'Release',
5+
6+
[Parameter()]
7+
[switch] $Force,
8+
9+
[Parameter()]
10+
[switch] $Publish
411
)
512
end {
613
& "$PSScriptRoot\tools\AssertRequiredModule.ps1" InvokeBuild 5.8.4 -Force:$Force.IsPresent
@@ -9,7 +16,11 @@ end {
916
File = "$PSScriptRoot/ClassExplorer.build.ps1"
1017
GenerateCodeCoverage = $true
1118
Force = $Force.IsPresent
12-
Configuration = 'Release'
19+
Configuration = $Configuration
20+
}
21+
22+
if ($Publish) {
23+
$invokeBuildSplat['Task'] = 'Publish'
1324
}
1425

1526
Invoke-Build @invokeBuildSplat

0 commit comments

Comments
 (0)