diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 3b45e0e..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,80 +0,0 @@ -name: Publish PowerShell Module - -on: - push: - tags: - - "v*.*.*" - -permissions: - contents: write - id-token: write - attestations: write - -jobs: - publish: - runs-on: ubuntu-latest - steps: - - name: Checkout Repository Code - uses: actions/checkout@v6 - - - name: Setup .NET - uses: actions/setup-dotnet@v5 - with: - dotnet-version: 8.0.x - - # Build the C# predictor and copy the DLL to the Module directory - - name: Build Module - shell: pwsh - run: ./Build.ps1 -Configuration Release - - # Ensure the config directory and file exist for both Linux and Windows runners, since the tests expect them to be present. - - name: Create Config Directory and File (Linux) - if: runner.os == 'Linux' - run: | - mkdir -p ~/.local/share/PSFavorite - echo '' > ~/.local/share/PSFavorite/Favorites.txt - - - name: Create Config Directory and File (Windows) - if: runner.os == 'Windows' - shell: pwsh - run: | - $configPath = "$env:LOCALAPPDATA\PSFavorite" - New-Item -ItemType Directory -Path $configPath -Force | Out-Null - New-Item -ItemType File -Path "$configPath\Favorites.txt" -Force | Out-Null - - # Ensure the built module passes all tests before proceeding - - name: Run Tests - shell: pwsh - run: | - Import-Module ./Module/PSFavorite.psd1 -Force - Invoke-Pester -Path ./Module/Tests -Output Detailed -PassThru - - # Zip the entire module directory (including the DLL) for attestation and release - - name: Zip Module - shell: pwsh - run: Compress-Archive -Path ./Module -DestinationPath ./PSFavorite.zip - - # actions/attest@v4 is the modern, consolidated action for all attestations. - # See: https://docs.github.com/en/actions/how-tos/secure-your-work/use-artifact-attestations/use-artifact-attestations - - name: Attest Build Provenance - uses: actions/attest@v4 - with: - subject-path: ${{ github.workspace }}/PSFavorite.zip - - # Create a release, attach the zipped module, and auto-generate notes from commits - # See: https://cli.github.com/manual/gh_release - - name: Create GitHub Release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh release create ${{ github.ref_name }} ./PSFavorite.zip \ - --title "Release ${{ github.ref_name }}" \ - --generate-notes - - # TODO: Enable this when ready to publish to PowerShell Gallery - # - name: Publish to PowerShell Gallery - # env: - # NUGET_KEY: ${{ secrets.NUGET_KEY }} - # shell: pwsh - # run: | - # Publish-Module -Path "./Module" -NuGetApiKey $env:NUGET_KEY -Verbose diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 7fc4651..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Test - -on: - push: - branches: ["main"] - paths: - - "Module/**" - - "Predictor/**" - - "Build.ps1" - pull_request: - branches: ["main"] - -jobs: - test: - name: Pester test (${{ matrix.os }}) - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest] - - steps: - - name: Checkout Repository Code - uses: actions/checkout@v6 - with: - fetch-depth: 1 # Fetch only the latest commit to speed up the checkout process - - - name: Setup .NET - uses: actions/setup-dotnet@v5 - with: - dotnet-version: 8.0.x - - - name: Build Module - shell: pwsh - run: ./Build.ps1 -Configuration Release - - - name: Create Config Directory and File (Linux) - if: runner.os == 'Linux' - run: | - mkdir -p ~/.local/share/PSFavorite - echo '' > ~/.local/share/PSFavorite/Favorites.txt - - - name: Create Config Directory and File (Windows) - if: runner.os == 'Windows' - shell: pwsh - run: | - $configPath = "$env:LOCALAPPDATA\PSFavorite" - New-Item -ItemType Directory -Path $configPath -Force | Out-Null - New-Item -ItemType File -Path "$configPath\Favorites.txt" -Force | Out-Null - - - name: Run Tests - shell: pwsh - run: | - Import-Module ./Module/PSFavorite.psd1 -Force - Invoke-Pester -Path ./Module/Tests -Output Detailed -PassThru diff --git a/Build.ps1 b/Build.ps1 index 8fcd8ca..22b6f6b 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -6,7 +6,7 @@ .PARAMETER Configuration The configuration of the build (`Debug` or `Release`) [Default: `Debug`] .PARAMETER TargetFramework - The target framework of the build (`net7.0` or `net8.0`) [Default: `net8.0`] + The target framework of the build (`net8.0`, `net9.0` or `net10.0`) [Default: `net9.0`] .PARAMETER Clean If specified, cleans the project before building. .EXAMPLE @@ -24,17 +24,17 @@ param( [ValidateSet('Debug', 'Release')] [string] $Configuration = 'Debug', - # The target framework of the build (`net7.0` or `net8.0`) [Default: `net8.0`] - [ValidateSet("net7.0", "net8.0")] + # The target framework of the build (`net8.0`, `net9.0` or `net10.0`) [Default: `net9.0`] + [ValidateSet("net8.0", "net9.0", "net10.0")] [ValidateNotNullOrEmpty()] - [string] $TargetFramework = "net8.0", + [string] $TargetFramework = "net9.0", # Clean the project before building [switch] $Clean ) # Path to the Predictor project -$Project = "$PSScriptRoot\Predictor\PSFavoritePredictor.csproj" +$Project = Join-Path $PSScriptRoot "Predictor" "PSFavoritePredictor.csproj" # Clean the project if the -Clean switch is specified if ($Clean) { @@ -55,16 +55,16 @@ if ($LASTEXITCODE -ne 0) { # Items to copy to the Module directory $Items = @( @{ - Source = "$PSScriptRoot\Predictor\bin\$Configuration\$TargetFramework\PSFavoritePredictor.dll" - Destination = "$PSScriptRoot\Module\Library\PSFavoritePredictor.dll" + Source = Join-Path $PSScriptRoot "Predictor" "bin" $Configuration $TargetFramework "PSFavoritePredictor.dll" + Destination = Join-Path $PSScriptRoot "Module" "Library" "PSFavoritePredictor.dll" }, @{ - Source = "$PSScriptRoot\README.md" - Destination = "$PSScriptRoot\Module\README.md" + Source = Join-Path $PSScriptRoot "README.md" + Destination = Join-Path $PSScriptRoot "Module" "README.md" }, @{ - Source = "$PSScriptRoot\LICENSE" - Destination = "$PSScriptRoot\Module\LICENSE" + Source = Join-Path $PSScriptRoot "LICENSE" + Destination = Join-Path $PSScriptRoot "Module" "LICENSE" } ) diff --git a/Predictor/PSFavoritePredictor.csproj b/Predictor/PSFavoritePredictor.csproj index c7a8bbf..e0f9a00 100644 --- a/Predictor/PSFavoritePredictor.csproj +++ b/Predictor/PSFavoritePredictor.csproj @@ -1,12 +1,11 @@ - - + - net8.0 + net9.0 enable enable PSFavoritePredictor