diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 27c8eca..c92dbae 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,24 +17,36 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: fetch-depth: 0 + - name: Setup dotnet + id: setup-dotnet + uses: actions/setup-dotnet@v5 + with: + global-json-file: src/global.json + - name: Setup wix run: | - dotnet.exe tool install --global wix --version 6.0.0 --verbosity diag + dotnet.exe tool install --global wix --version 6.0.2 --verbosity diag - wix.exe extension add WixToolset.UI.wixext/6.0.0 --global + wix.exe extension add WixToolset.UI.wixext/6.0.2 --global wix.exe extension list --global - name: Generate version property id: version run: | + $pattern = '^v(((\d+\.\d+\.\d+\.\d+)(?:-[a-z]+\.\d+)?)-(\d+-g.+))' $tag = git.exe describe --tags --long - $version = [version]::new($tag.Split('-')[0].TrimStart('v')) + $version = [System.Text.RegularExpressions.Regex]::Match($tag, $pattern).Groups[3].Value + $fullVersion = [System.Text.RegularExpressions.Regex]::Match($tag, $pattern).Groups[2].Value + $gitCommitInfo = [System.Text.RegularExpressions.Regex]::Match($tag, $pattern).Groups[4].Value + $informationalVersion = '{0}+{1}' -f $fullVersion,$gitCommitInfo echo "version=$version" >> $env:GITHUB_OUTPUT + echo "fullVersion=$fullVersion" >> $env:GITHUB_OUTPUT + echo "informationalVersion=$informationalVersion" >> $env:GITHUB_OUTPUT - name: Run tests run: dotnet.exe test .\src\PSDataProtection.sln --configuration Release --runtime win-x64 @@ -100,7 +112,7 @@ jobs: - name: Publish release if: github.ref_type == 'tag' - run: gh.exe release create v${{ steps.version.outputs.version }} --title v${{ steps.version.outputs.version }} --notes 'PowerShell data protection module.' ps-data-protection.msi + run: gh.exe release create v${{ steps.version.outputs.fullVersion }} --title v${{ steps.version.outputs.fullVersion }} --notes 'PowerShell data protection module.' ps-data-protection.msi env: # Requires a personal access token with a fine-grained permission of contents:read/write. GH_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }} diff --git a/src/PSDataProtection/PSDataProtection.csproj b/src/PSDataProtection/PSDataProtection.csproj index 6a67a26..89451cf 100644 --- a/src/PSDataProtection/PSDataProtection.csproj +++ b/src/PSDataProtection/PSDataProtection.csproj @@ -10,7 +10,7 @@ - + @@ -27,16 +27,18 @@ - + - ^v((.+)-(\d+)-g(.+)) - $([System.Text.RegularExpressions.Regex]::Match($(GitTag), $(PatternGitTag)).Groups[2].Value) - $([System.Text.RegularExpressions.Regex]::Match($(GitTag), $(PatternGitTag)).Groups[2].Value) - $([System.Text.RegularExpressions.Regex]::Match($(GitTag), $(PatternGitTag)).Groups[2].Value) - $([System.Text.RegularExpressions.Regex]::Match($(GitTag), $(PatternGitTag)).Groups[1].Value) + ^v(((\d+\.\d+\.\d+\.\d+)(?:-[a-z]+\.\d+)?)-(\d+-g.+)) + $([System.Text.RegularExpressions.Regex]::Match($(GitTag), $(PatternGitTag)).Groups[3].Value) + $([System.Text.RegularExpressions.Regex]::Match($(GitTag), $(PatternGitTag)).Groups[3].Value) + $([System.Text.RegularExpressions.Regex]::Match($(GitTag), $(PatternGitTag)).Groups[3].Value) + $([System.Text.RegularExpressions.Regex]::Match($(GitTag), $(PatternGitTag)).Groups[2].Value) + $([System.Text.RegularExpressions.Regex]::Match($(GitTag), $(PatternGitTag)).Groups[4].Value) + $(FullVersion)+$(GitCommitInfo) diff --git a/src/Tests/IntegrationTests.cs b/src/Tests/IntegrationTests.cs index e1b1d82..75e7ab5 100644 --- a/src/Tests/IntegrationTests.cs +++ b/src/Tests/IntegrationTests.cs @@ -10,12 +10,11 @@ namespace Tests; public sealed class IntegrationTests : IDisposable { - private readonly Runspace runSpace; private readonly PowerShell powerShell; public IntegrationTests() { - var initialSessionState = InitialSessionState.Create(); + var initialSessionState = InitialSessionState.CreateDefault2(); var entry1 = new SessionStateCmdletEntry("New-DataProtectionSecret", typeof(NewDataProtectionSecretCommand), null); initialSessionState.Commands.Add(entry1); @@ -23,11 +22,7 @@ public IntegrationTests() var entry2 = new SessionStateCmdletEntry("Read-DataProtectionSecret", typeof(ReadDataProtectionSecretCommand), null); initialSessionState.Commands.Add(entry2); - this.runSpace = RunspaceFactory.CreateRunspace(initialSessionState); - this.powerShell = PowerShell.Create(); - - this.runSpace.Open(); - this.powerShell.Runspace = this.runSpace; + this.powerShell = PowerShell.Create(initialSessionState); } public static TheoryData NewDataProtectionSecretArguments() => new() @@ -182,9 +177,5 @@ public void SecureStringAsObjectInPipelineShouldPass(string data, DataProtection } /// - public void Dispose() - { - this.powerShell.Dispose(); - this.runSpace.Dispose(); - } + public void Dispose() => this.powerShell.Dispose(); } \ No newline at end of file diff --git a/src/Tests/ParameterTests.cs b/src/Tests/ParameterTests.cs index dcced93..c660370 100644 --- a/src/Tests/ParameterTests.cs +++ b/src/Tests/ParameterTests.cs @@ -9,12 +9,11 @@ namespace Tests; public sealed class ParameterTests : IDisposable { - private readonly Runspace runSpace; private readonly PowerShell powerShell; public ParameterTests() { - var initialSessionState = InitialSessionState.Create(); + var initialSessionState = InitialSessionState.CreateDefault2(); var entry1 = new SessionStateCmdletEntry("New-DataProtectionSecret", typeof(NewDataProtectionSecretCommand), null); initialSessionState.Commands.Add(entry1); @@ -22,11 +21,7 @@ public ParameterTests() var entry2 = new SessionStateCmdletEntry("Read-DataProtectionSecret", typeof(ReadDataProtectionSecretCommand), null); initialSessionState.Commands.Add(entry2); - this.runSpace = RunspaceFactory.CreateRunspace(initialSessionState); - this.powerShell = PowerShell.Create(); - - this.runSpace.Open(); - this.powerShell.Runspace = this.runSpace; + this.powerShell = PowerShell.Create(initialSessionState); } [Fact] @@ -120,9 +115,5 @@ public void ReadDataProtectionSecretWithInvalidScopeShouldThrow() } /// - public void Dispose() - { - this.powerShell.Dispose(); - this.runSpace.Dispose(); - } + public void Dispose() => this.powerShell.Dispose(); } \ No newline at end of file diff --git a/src/Tests/Tests.csproj b/src/Tests/Tests.csproj index 0aa8581..9df6bd9 100644 --- a/src/Tests/Tests.csproj +++ b/src/Tests/Tests.csproj @@ -9,9 +9,9 @@ - + - + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/global.json b/src/global.json new file mode 100644 index 0000000..c3e62a0 --- /dev/null +++ b/src/global.json @@ -0,0 +1,7 @@ +{ + "sdk": { + "version": "10.0.100", + "rollForward": "latestFeature", + "allowPrerelease": true + } +} \ No newline at end of file