Skip to content

Commit b63765a

Browse files
authored
⬆️ SecretManagement 1.1.0 Compatibility (#55)
SecretManagement 1.1.0 moves the vault extension into its own runspace and adds a new Unlock-SecretVault mechanism. This adds support for that new operating model.
1 parent 40960ab commit b63765a

22 files changed

+342
-255
lines changed

.config/RequiredModules.psd1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
@{
2-
'Microsoft.Powershell.SecretManagement' = '1.0.0'
3-
}
2+
'Microsoft.Powershell.SecretManagement' = '1.1.0'
3+
'PowerConfig' = '0.1.3'
4+
'PSFramework' = '1.6.205'
5+
}

.github/workflows/press.yml

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ on:
99
- production
1010
tags:
1111
- '*'
12-
release:
13-
types:
12+
release:
13+
types:
1414
- published
1515
pull_request:
1616
branches:
@@ -46,7 +46,7 @@ jobs:
4646
~/.local/share/Press
4747
~/AppData/Local/Press
4848
~/.nuget/packages/gitversion.tool
49-
key: build-${{ hashFiles('Source/.config/Requirements.psd1') }}
49+
key: build-${{ hashFiles('.config/RequiredModules.psd1') }}
5050

5151
- if: steps.debugStatus.outputs.stepDebug
5252
name: 🔬 Powershell Environment Information
@@ -93,7 +93,7 @@ jobs:
9393
- if: always() && runner.os != 'Windows' && steps.debugStatus.outputs.runnerDebug
9494
name: 🐛 Debug via SSH if ACTIONS_RUNNER_DEBUG secret is set
9595
uses: lhotari/action-upterm@v1
96-
96+
9797
#TODO: Move to dedicated function
9898
- name: 📦 Update Draft Github Release
9999
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/ci'
@@ -111,14 +111,14 @@ jobs:
111111
fail-fast: true
112112
matrix:
113113
os:
114-
- ubuntu-latest
114+
# - ubuntu-latest
115115
- ubuntu-20.04
116116
- ubuntu-18.04
117-
- ubuntu-16.04
118-
- windows-latest
117+
# - ubuntu-16.04
118+
# - windows-latest
119119
- windows-2019
120-
- windows-2016
121-
- macos-latest
120+
# - windows-2016
121+
# - macos-latest
122122
- macos-11.0
123123
- macos-10.15
124124
steps:
@@ -141,15 +141,13 @@ jobs:
141141
~/.nuget/packages/gitversion.tool
142142
key: test-${{ matrix.os }}-${{ hashFiles('Source/.config/RequiredModules.psd1') }}
143143

144-
#Meta: We don't test on 5.1 for using the module
145144
- name: ➕ Restore Built Powershell Module
146145
uses: actions/download-artifact@v2
147146
with:
148147
name: PSModule
149148
#TODO: Pull this from environment setup
150149
path: BuildOutput/${{ github.event.repository.name }}
151150

152-
#TODO: Remove redundancy when https://github.com/actions/runner/issues/444 is implemented
153151
- name: 🧪 Test Powershell 7+
154152
shell: pwsh
155153
run: |
@@ -161,18 +159,6 @@ jobs:
161159
162160
. ./build.ps1 'Test'
163161
164-
#Meta: We don't test on 5.1 for using the module for Press
165-
# - if: runner.os == 'Windows' && github.repository != 'JustinGrote/Press'
166-
# name: 🧪 Test Windows Powershell
167-
# shell: powershell
168-
# run: |
169-
# if ('${{secrets.ACTIONS_STEP_DEBUG}}') {$verbosePreference = 'continue'}
170-
# #Press Meta
171-
# if ('${{ github.event.repository.name }}' -eq 'Press') {
172-
# $GLOBAL:PressModulePath = Resolve-Path ./BuildOutput/Press/Press.psd1
173-
# }
174-
# . ./build.ps1 'Test'
175-
176162
deployPrerelease:
177163
name: 🚀 Deploy Prelease Module
178164
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
@@ -192,7 +178,8 @@ jobs:
192178
shell: pwsh
193179
run: |
194180
if (-not '${{ secrets.PS_GALLERY_KEY }}') {throw 'You need to configure a PS_GALLERY_KEY secret for this environment with your Powershell Gallery API Key'}
195-
Install-Module Microsoft.Powershell.SecretManagement -MinimumVersion 1.0.0 -Force
181+
Install-Module Microsoft.Powershell.SecretManagement -RequiredVersion 1.1.0 -Force
182+
Install-Module PSFramework -RequiredVersion 1.6.205 -Force -AllowClobber
196183
Publish-Module -Verbose -Name $PWD/BuildOutput/${{ github.event.repository.name }} -NugetApiKey ${{ secrets.PS_GALLERY_KEY }}
197184
198185
deploy:
@@ -214,5 +201,6 @@ jobs:
214201
shell: pwsh
215202
run: |
216203
if (-not '${{ secrets.PS_GALLERY_KEY }}') {throw 'You need to configure a PS_GALLERY_KEY secret for this environment with your Powershell Gallery API Key'}
217-
Install-Module Microsoft.Powershell.SecretManagement -MinimumVersion 1.0.0 -Force
218-
Publish-Module -Verbose -Name $PWD/BuildOutput/${{ github.event.repository.name }} -NugetApiKey ${{ secrets.PS_GALLERY_KEY }}
204+
Install-Module Microsoft.Powershell.SecretManagement -RequiredVersion 1.1.0 -Force
205+
Install-Module PSFramework -RequiredVersion 1.6.205 -Force -AllowClobber
206+
Publish-Module -Verbose -Name $PWD/BuildOutput/${{ github.event.repository.name }} -NugetApiKey ${{ secrets.PS_GALLERY_KEY }}

PSModule.build.ps1

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,51 @@
1+
2+
if (-not (Get-Module PowerConfig -ErrorAction SilentlyContinue)) {
3+
try {
4+
Import-Module PowerConfig -ErrorAction Stop
5+
} catch {
6+
Install-Module PowerConfig -AllowPrerelease -Force
7+
Import-Module PowerConfig -ErrorAction Stop
8+
}
9+
}
110
if (-not (Get-Module Press -ErrorAction SilentlyContinue)) {
211
try {
312
Import-Module Press -ErrorAction Stop
413
} catch {
5-
Install-Module Press -AllowPrerelease -Force
14+
Install-Module Press -Force
615
Import-Module Press -ErrorAction Stop
716
}
817
}
18+
if (-not (Get-Module 'Microsoft.Powershell.SecretManagement' -ErrorAction SilentlyContinue)) {
19+
try {
20+
Import-Module 'Microsoft.Powershell.SecretManagement' -ErrorAction Stop
21+
} catch {
22+
Install-Module 'Microsoft.Powershell.SecretManagement' -AllowPrerelease -RequiredVersion '1.1.0' -Force
23+
Import-Module 'Microsoft.Powershell.SecretManagement' -ErrorAction Stop
24+
}
25+
}
26+
if (-not (Get-Module 'PSFramework' -ErrorAction SilentlyContinue)) {
27+
try {
28+
Import-Module 'PSFramework' -ErrorAction Stop
29+
} catch {
30+
Install-Module 'PSFramework' -AllowPrerelease -RequiredVersion '1.6.205' -Force -AllowClobber
31+
Import-Module 'PSFramework' -ErrorAction Stop
32+
}
33+
}
34+
935
. Press.Tasks
1036

1137
Task Press.CopyModuleFiles @{
12-
Inputs = {
38+
Inputs = {
1339
Get-ChildItem -File -Recurse $PressSetting.General.SrcRootDir
1440
$SCRIPT:IncludeFiles = (
1541
(Get-ChildItem -File -Recurse "$($PressSetting.General.SrcRootDir)\SecretManagement.KeePass.Extension") |
1642
Resolve-Path
1743
)
1844
$IncludeFiles
1945
}
20-
Outputs = {
46+
Outputs = {
2147
$buildItems = Get-ChildItem -File -Recurse $PressSetting.Build.ModuleOutDir
22-
if ($buildItems) { $buildItems } else { 'EmptyBuildOutputFolder' }
48+
if ($buildItems) { $buildItems } else { 'EmptyBuildOutputFolder' }
2349
}
2450
Jobs = {
2551
Remove-BuildItem $PressSetting.Build.ModuleOutDir
@@ -45,4 +71,8 @@ Task CopyPoshKeePass -After Press.CopyModuleFiles {
4571
Copy-Item $PKPExtensionPath -Recurse -Force -Exclude '*.Tests.ps1' -Destination $PressSetting.Build.ModuleOutDir -Container
4672
}
4773

48-
Task Package Press.Package.Zip
74+
Task Package Press.Package.Zip
75+
76+
Task Press.Test.Pester.WindowsPowershell {
77+
Write-Warning 'Windows Powershell Tests cannot currently be run due to a bug. Run the tests manually. Remove when https://github.com/pester/Pester/issues/1974 is closed'
78+
}

0 commit comments

Comments
 (0)