Skip to content

Commit

Permalink
⬆️ SecretManagement 1.1.0 Compatibility (#55)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JustinGrote authored Aug 22, 2021
1 parent 40960ab commit b63765a
Show file tree
Hide file tree
Showing 22 changed files with 342 additions and 255 deletions.
6 changes: 4 additions & 2 deletions .config/RequiredModules.psd1
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@{
'Microsoft.Powershell.SecretManagement' = '1.0.0'
}
'Microsoft.Powershell.SecretManagement' = '1.1.0'
'PowerConfig' = '0.1.3'
'PSFramework' = '1.6.205'
}
40 changes: 14 additions & 26 deletions .github/workflows/press.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ on:
- production
tags:
- '*'
release:
types:
release:
types:
- published
pull_request:
branches:
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
~/.local/share/Press
~/AppData/Local/Press
~/.nuget/packages/gitversion.tool
key: build-${{ hashFiles('Source/.config/Requirements.psd1') }}
key: build-${{ hashFiles('.config/RequiredModules.psd1') }}

- if: steps.debugStatus.outputs.stepDebug
name: 🔬 Powershell Environment Information
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
- if: always() && runner.os != 'Windows' && steps.debugStatus.outputs.runnerDebug
name: 🐛 Debug via SSH if ACTIONS_RUNNER_DEBUG secret is set
uses: lhotari/action-upterm@v1

#TODO: Move to dedicated function
- name: 📦 Update Draft Github Release
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/ci'
Expand All @@ -111,14 +111,14 @@ jobs:
fail-fast: true
matrix:
os:
- ubuntu-latest
# - ubuntu-latest
- ubuntu-20.04
- ubuntu-18.04
- ubuntu-16.04
- windows-latest
# - ubuntu-16.04
# - windows-latest
- windows-2019
- windows-2016
- macos-latest
# - windows-2016
# - macos-latest
- macos-11.0
- macos-10.15
steps:
Expand All @@ -141,15 +141,13 @@ jobs:
~/.nuget/packages/gitversion.tool
key: test-${{ matrix.os }}-${{ hashFiles('Source/.config/RequiredModules.psd1') }}

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

#TODO: Remove redundancy when https://github.com/actions/runner/issues/444 is implemented
- name: 🧪 Test Powershell 7+
shell: pwsh
run: |
Expand All @@ -161,18 +159,6 @@ jobs:
. ./build.ps1 'Test'
#Meta: We don't test on 5.1 for using the module for Press
# - if: runner.os == 'Windows' && github.repository != 'JustinGrote/Press'
# name: 🧪 Test Windows Powershell
# shell: powershell
# run: |
# if ('${{secrets.ACTIONS_STEP_DEBUG}}') {$verbosePreference = 'continue'}
# #Press Meta
# if ('${{ github.event.repository.name }}' -eq 'Press') {
# $GLOBAL:PressModulePath = Resolve-Path ./BuildOutput/Press/Press.psd1
# }
# . ./build.ps1 'Test'

deployPrerelease:
name: 🚀 Deploy Prelease Module
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
Expand All @@ -192,7 +178,8 @@ jobs:
shell: pwsh
run: |
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'}
Install-Module Microsoft.Powershell.SecretManagement -MinimumVersion 1.0.0 -Force
Install-Module Microsoft.Powershell.SecretManagement -RequiredVersion 1.1.0 -Force
Install-Module PSFramework -RequiredVersion 1.6.205 -Force -AllowClobber
Publish-Module -Verbose -Name $PWD/BuildOutput/${{ github.event.repository.name }} -NugetApiKey ${{ secrets.PS_GALLERY_KEY }}
deploy:
Expand All @@ -214,5 +201,6 @@ jobs:
shell: pwsh
run: |
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'}
Install-Module Microsoft.Powershell.SecretManagement -MinimumVersion 1.0.0 -Force
Publish-Module -Verbose -Name $PWD/BuildOutput/${{ github.event.repository.name }} -NugetApiKey ${{ secrets.PS_GALLERY_KEY }}
Install-Module Microsoft.Powershell.SecretManagement -RequiredVersion 1.1.0 -Force
Install-Module PSFramework -RequiredVersion 1.6.205 -Force -AllowClobber
Publish-Module -Verbose -Name $PWD/BuildOutput/${{ github.event.repository.name }} -NugetApiKey ${{ secrets.PS_GALLERY_KEY }}
40 changes: 35 additions & 5 deletions PSModule.build.ps1
Original file line number Diff line number Diff line change
@@ -1,25 +1,51 @@

if (-not (Get-Module PowerConfig -ErrorAction SilentlyContinue)) {
try {
Import-Module PowerConfig -ErrorAction Stop
} catch {
Install-Module PowerConfig -AllowPrerelease -Force
Import-Module PowerConfig -ErrorAction Stop
}
}
if (-not (Get-Module Press -ErrorAction SilentlyContinue)) {
try {
Import-Module Press -ErrorAction Stop
} catch {
Install-Module Press -AllowPrerelease -Force
Install-Module Press -Force
Import-Module Press -ErrorAction Stop
}
}
if (-not (Get-Module 'Microsoft.Powershell.SecretManagement' -ErrorAction SilentlyContinue)) {
try {
Import-Module 'Microsoft.Powershell.SecretManagement' -ErrorAction Stop
} catch {
Install-Module 'Microsoft.Powershell.SecretManagement' -AllowPrerelease -RequiredVersion '1.1.0' -Force
Import-Module 'Microsoft.Powershell.SecretManagement' -ErrorAction Stop
}
}
if (-not (Get-Module 'PSFramework' -ErrorAction SilentlyContinue)) {
try {
Import-Module 'PSFramework' -ErrorAction Stop
} catch {
Install-Module 'PSFramework' -AllowPrerelease -RequiredVersion '1.6.205' -Force -AllowClobber
Import-Module 'PSFramework' -ErrorAction Stop
}
}

. Press.Tasks

Task Press.CopyModuleFiles @{
Inputs = {
Inputs = {
Get-ChildItem -File -Recurse $PressSetting.General.SrcRootDir
$SCRIPT:IncludeFiles = (
(Get-ChildItem -File -Recurse "$($PressSetting.General.SrcRootDir)\SecretManagement.KeePass.Extension") |
Resolve-Path
)
$IncludeFiles
}
Outputs = {
Outputs = {
$buildItems = Get-ChildItem -File -Recurse $PressSetting.Build.ModuleOutDir
if ($buildItems) { $buildItems } else { 'EmptyBuildOutputFolder' }
if ($buildItems) { $buildItems } else { 'EmptyBuildOutputFolder' }
}
Jobs = {
Remove-BuildItem $PressSetting.Build.ModuleOutDir
Expand All @@ -45,4 +71,8 @@ Task CopyPoshKeePass -After Press.CopyModuleFiles {
Copy-Item $PKPExtensionPath -Recurse -Force -Exclude '*.Tests.ps1' -Destination $PressSetting.Build.ModuleOutDir -Container
}

Task Package Press.Package.Zip
Task Package Press.Package.Zip

Task Press.Test.Pester.WindowsPowershell {
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'
}
Loading

0 comments on commit b63765a

Please sign in to comment.