From 1beb2852e79b0bab32050d68484386a1618d5cbd Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 22 Jan 2026 19:42:16 +0100 Subject: [PATCH 01/17] Update workflow configurations --- .github/workflows/Action-Test.yml | 4 ++-- .github/workflows/Auto-Release.yml | 2 +- .github/workflows/Linter.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 957a340..ad5736d 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -23,7 +23,7 @@ jobs: steps: # Need to check out as part of the test, as its a local action - name: Checkout repo - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false @@ -39,7 +39,7 @@ jobs: steps: # Need to check out as part of the test, as its a local action - name: Checkout repo - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false diff --git a/.github/workflows/Auto-Release.yml b/.github/workflows/Auto-Release.yml index c09b24f..2a0d540 100644 --- a/.github/workflows/Auto-Release.yml +++ b/.github/workflows/Auto-Release.yml @@ -26,7 +26,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Code - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false diff --git a/.github/workflows/Linter.yml b/.github/workflows/Linter.yml index 6d40bc9..7c46400 100644 --- a/.github/workflows/Linter.yml +++ b/.github/workflows/Linter.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repo - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: fetch-depth: 0 persist-credentials: false From 74403e9ec98cf69212e1d4bdf3e28cfd1b810ac3 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 23 Jan 2026 16:48:51 +0100 Subject: [PATCH 02/17] Add important file change detection for build/test optimization --- scripts/Settings.schema.json | 4 ++ scripts/main.ps1 | 79 +++++++++++++++++++++++++++++++----- 2 files changed, 73 insertions(+), 10 deletions(-) diff --git a/scripts/Settings.schema.json b/scripts/Settings.schema.json index 898b5d3..fd489b4 100644 --- a/scripts/Settings.schema.json +++ b/scripts/Settings.schema.json @@ -293,6 +293,10 @@ "type": "string", "description": "Working directory path" }, + "HasImportantChanges": { + "type": "boolean", + "description": "Indicates if important files have changed in the PR (src/**, examples/**, README.md, .github/workflows/Process-PSModule.yml)" + }, "Run": { "type": "object", "description": "Runtime execution flags", diff --git a/scripts/main.ps1 b/scripts/main.ps1 index c7bbdb7..b078678 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -241,6 +241,59 @@ LogGroup 'Calculate Job Run Conditions:' { 'None' } + # Check if important files have changed in the PR + # Important files for module and docs publish: + # - .github/workflows/Process-PSModule.yml + # - src/** + # - examples/** + # - README.md + $hasImportantChanges = $false + if ($isPR -and $pullRequest.Number) { + LogGroup 'Check for Important File Changes' { + $owner = $env:GITHUB_REPOSITORY_OWNER + $repo = $env:GITHUB_REPOSITORY_NAME + $prNumber = $pullRequest.Number + + Write-Host "Fetching changed files for PR #$prNumber..." + $changedFiles = Invoke-GitHubAPI -ApiEndpoint "/repos/$owner/$repo/pulls/$prNumber/files" -Method GET | + Select-Object -ExpandProperty Response | + Select-Object -ExpandProperty filename + + Write-Host "Changed files ($($changedFiles.Count)):" + $changedFiles | ForEach-Object { Write-Host " - $_" } + + # Define important file patterns + $importantPatterns = @( + '^\.github/workflows/Process-PSModule\.yml$' + '^src/' + '^examples/' + '^README\.md$' + ) + + # Check if any changed file matches an important pattern + foreach ($file in $changedFiles) { + foreach ($pattern in $importantPatterns) { + if ($file -match $pattern) { + $hasImportantChanges = $true + Write-Host "Important file changed: [$file] (matches pattern: $pattern)" + break + } + } + if ($hasImportantChanges) { break } + } + + if ($hasImportantChanges) { + Write-Host '✓ Important files have changed - build/test stages will run' + } else { + Write-Host '✗ No important files changed - build/test stages may be skipped for open PRs' + } + } + } else { + # Not a PR event or no PR number - consider as having important changes (e.g., workflow_dispatch, schedule) + $hasImportantChanges = $true + Write-Host 'Not a PR event or missing PR number - treating as having important changes' + } + [pscustomobject]@{ isPR = $isPR isOpenOrUpdatedPR = $isOpenOrUpdatedPR @@ -252,6 +305,7 @@ LogGroup 'Calculate Job Run Conditions:' { hasPrereleaseLabel = $hasPrereleaseLabel shouldPrerelease = $shouldPrerelease ReleaseType = $releaseType + HasImportantChanges = $hasImportantChanges } | Format-List | Out-String } @@ -433,28 +487,33 @@ LogGroup 'Calculate Job Run Conditions:' { $settings.Publish.Module | Add-Member -MemberType NoteProperty -Name ReleaseType -Value $releaseType -Force $settings.Publish.Module.AutoCleanup = $shouldAutoCleanup + # For open PRs, we only want to run build/test stages if important files changed + # OR if we're creating a prerelease. For merged PRs, workflow_dispatch, schedule - always run. + $shouldRunBuildTest = $isNotAbandonedPR -and ($hasImportantChanges -or $shouldPrerelease -or $isMergedPR) + # Create Run object with all job-specific conditions $run = [pscustomobject]@{ LintRepository = $isOpenOrUpdatedPR -and (-not $settings.Linter.Skip) - BuildModule = $isNotAbandonedPR -and (-not $settings.Build.Module.Skip) - TestSourceCode = $isNotAbandonedPR -and ($null -ne $settings.TestSuites.SourceCode) - LintSourceCode = $isNotAbandonedPR -and ($null -ne $settings.TestSuites.SourceCode) - TestModule = $isNotAbandonedPR -and ($null -ne $settings.TestSuites.PSModule) - BeforeAllModuleLocal = $isNotAbandonedPR -and ($null -ne $settings.TestSuites.Module) - TestModuleLocal = $isNotAbandonedPR -and ($null -ne $settings.TestSuites.Module) + BuildModule = $shouldRunBuildTest -and (-not $settings.Build.Module.Skip) + TestSourceCode = $shouldRunBuildTest -and ($null -ne $settings.TestSuites.SourceCode) + LintSourceCode = $shouldRunBuildTest -and ($null -ne $settings.TestSuites.SourceCode) + TestModule = $shouldRunBuildTest -and ($null -ne $settings.TestSuites.PSModule) + BeforeAllModuleLocal = $shouldRunBuildTest -and ($null -ne $settings.TestSuites.Module) + TestModuleLocal = $shouldRunBuildTest -and ($null -ne $settings.TestSuites.Module) AfterAllModuleLocal = $true # Always runs if Test-ModuleLocal was not skipped - GetTestResults = $isNotAbandonedPR -and (-not $settings.Test.TestResults.Skip) -and ( + GetTestResults = $shouldRunBuildTest -and (-not $settings.Test.TestResults.Skip) -and ( ($null -ne $settings.TestSuites.SourceCode) -or ($null -ne $settings.TestSuites.PSModule) -or ($null -ne $settings.TestSuites.Module) ) - GetCodeCoverage = $isNotAbandonedPR -and (-not $settings.Test.CodeCoverage.Skip) -and ( + GetCodeCoverage = $shouldRunBuildTest -and (-not $settings.Test.CodeCoverage.Skip) -and ( ($null -ne $settings.TestSuites.PSModule) -or ($null -ne $settings.TestSuites.Module) ) PublishModule = ($releaseType -ne 'None') -or $shouldAutoCleanup - BuildDocs = $isNotAbandonedPR -and (-not $settings.Build.Docs.Skip) - BuildSite = $isNotAbandonedPR -and (-not $settings.Build.Site.Skip) + BuildDocs = $shouldRunBuildTest -and (-not $settings.Build.Docs.Skip) + BuildSite = $shouldRunBuildTest -and (-not $settings.Build.Site.Skip) PublishSite = $isMergedPR -and $isTargetDefaultBranch } $settings | Add-Member -MemberType NoteProperty -Name Run -Value $run + $settings | Add-Member -MemberType NoteProperty -Name HasImportantChanges -Value $hasImportantChanges Write-Host 'Job Run Conditions:' $run | Format-List | Out-String From 0bb4e7dcda11c39137291a8504255f0157b8d9cb Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 23 Jan 2026 17:38:21 +0100 Subject: [PATCH 03/17] Require important file changes for prerelease --- scripts/main.ps1 | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index b078678..68e82d5 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -229,17 +229,6 @@ LogGroup 'Calculate Job Run Conditions:' { $prLabels = @($pullRequest.labels.name) $hasPrereleaseLabel = ($prLabels | Where-Object { $prereleaseLabels -contains $_ }).Count -gt 0 $isOpenOrLabeledPR = $isPR -and $pullRequestAction -in @('opened', 'reopened', 'synchronize', 'labeled') - $shouldPrerelease = $isOpenOrLabeledPR -and $hasPrereleaseLabel - - # Determine ReleaseType - what type of release to create - # Values: 'Release', 'Prerelease', 'None' - $releaseType = if ($isMergedPR -and $isTargetDefaultBranch) { - 'Release' - } elseif ($shouldPrerelease) { - 'Prerelease' - } else { - 'None' - } # Check if important files have changed in the PR # Important files for module and docs publish: @@ -285,7 +274,7 @@ LogGroup 'Calculate Job Run Conditions:' { if ($hasImportantChanges) { Write-Host '✓ Important files have changed - build/test stages will run' } else { - Write-Host '✗ No important files changed - build/test stages may be skipped for open PRs' + Write-Host '✗ No important files changed - build/test stages will be skipped' } } } else { @@ -294,6 +283,20 @@ LogGroup 'Calculate Job Run Conditions:' { Write-Host 'Not a PR event or missing PR number - treating as having important changes' } + # Prerelease requires both: prerelease label AND important file changes + # No point creating a prerelease if only non-module files changed + $shouldPrerelease = $isOpenOrLabeledPR -and $hasPrereleaseLabel -and $hasImportantChanges + + # Determine ReleaseType - what type of release to create + # Values: 'Release', 'Prerelease', 'None' + $releaseType = if ($isMergedPR -and $isTargetDefaultBranch) { + 'Release' + } elseif ($shouldPrerelease) { + 'Prerelease' + } else { + 'None' + } + [pscustomobject]@{ isPR = $isPR isOpenOrUpdatedPR = $isOpenOrUpdatedPR @@ -487,9 +490,10 @@ LogGroup 'Calculate Job Run Conditions:' { $settings.Publish.Module | Add-Member -MemberType NoteProperty -Name ReleaseType -Value $releaseType -Force $settings.Publish.Module.AutoCleanup = $shouldAutoCleanup - # For open PRs, we only want to run build/test stages if important files changed - # OR if we're creating a prerelease. For merged PRs, workflow_dispatch, schedule - always run. - $shouldRunBuildTest = $isNotAbandonedPR -and ($hasImportantChanges -or $shouldPrerelease -or $isMergedPR) + # For open PRs, we only want to run build/test stages if important files changed. + # For merged PRs, workflow_dispatch, schedule - $hasImportantChanges is already true. + # Note: $shouldPrerelease already requires $hasImportantChanges, so no separate check needed. + $shouldRunBuildTest = $isNotAbandonedPR -and $hasImportantChanges # Create Run object with all job-specific conditions $run = [pscustomobject]@{ From ca41da728d0e5ed6b3945734076165316b3c12e9 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 23 Jan 2026 18:08:05 +0100 Subject: [PATCH 04/17] Only publish when important files changed, cleanup still runs --- scripts/main.ps1 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 68e82d5..b401a22 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -289,7 +289,9 @@ LogGroup 'Calculate Job Run Conditions:' { # Determine ReleaseType - what type of release to create # Values: 'Release', 'Prerelease', 'None' - $releaseType = if ($isMergedPR -and $isTargetDefaultBranch) { + # Release only happens when important files changed (actual module code/docs) + # Merged PRs without important changes should only trigger cleanup, not a new release + $releaseType = if ($isMergedPR -and $isTargetDefaultBranch -and $hasImportantChanges) { 'Release' } elseif ($shouldPrerelease) { 'Prerelease' @@ -483,8 +485,9 @@ if ($settings.Test.Skip) { # Calculate job-specific conditions and add to settings LogGroup 'Calculate Job Run Conditions:' { # Calculate if prereleases should be cleaned up: - # True if (Release or Abandoned PR) AND user has AutoCleanup enabled (defaults to true) - $shouldAutoCleanup = (($releaseType -eq 'Release') -or $isAbandonedPR) -and ($settings.Publish.Module.AutoCleanup -eq $true) + # True if (Release, merged PR to default branch, or Abandoned PR) AND user has AutoCleanup enabled (defaults to true) + # Even if no important files changed, we still want to cleanup prereleases when merging to default branch + $shouldAutoCleanup = (($releaseType -eq 'Release') -or ($isMergedPR -and $isTargetDefaultBranch) -or $isAbandonedPR) -and ($settings.Publish.Module.AutoCleanup -eq $true) # Update Publish.Module with computed release values $settings.Publish.Module | Add-Member -MemberType NoteProperty -Name ReleaseType -Value $releaseType -Force @@ -514,7 +517,7 @@ LogGroup 'Calculate Job Run Conditions:' { PublishModule = ($releaseType -ne 'None') -or $shouldAutoCleanup BuildDocs = $shouldRunBuildTest -and (-not $settings.Build.Docs.Skip) BuildSite = $shouldRunBuildTest -and (-not $settings.Build.Site.Skip) - PublishSite = $isMergedPR -and $isTargetDefaultBranch + PublishSite = $isMergedPR -and $isTargetDefaultBranch -and $hasImportantChanges } $settings | Add-Member -MemberType NoteProperty -Name Run -Value $run $settings | Add-Member -MemberType NoteProperty -Name HasImportantChanges -Value $hasImportantChanges From 76481ac926d9bdbb28398d9f625a48126ba94240 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 23 Jan 2026 19:53:26 +0100 Subject: [PATCH 05/17] Add PR comment when no significant changes detected --- scripts/main.ps1 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index b401a22..aa9a299 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -275,6 +275,25 @@ LogGroup 'Calculate Job Run Conditions:' { Write-Host '✓ Important files have changed - build/test stages will run' } else { Write-Host '✗ No important files changed - build/test stages will be skipped' + + # Add a comment to open PRs explaining why build/test is skipped + if ($isOpenOrUpdatedPR) { + $commentBody = @" +## ℹ️ No Significant Changes Detected + +This PR does not contain changes to files that would trigger a new release: +- ``src/**`` - Module source code +- ``examples/**`` - Example scripts +- ``README.md`` - Documentation +- ``.github/workflows/Process-PSModule.yml`` - Workflow configuration + +**Build and test stages will be skipped** for this PR. + +If you believe this is incorrect, please verify that your changes are in the correct locations. +"@ + Write-Host 'Adding comment to PR about skipped stages...' + Add-GitHubPullRequestComment -Owner $owner -Repo $repo -PullRequestNumber $prNumber -Body $commentBody + } } } } else { From 55c31095687eb115f97a905c1c92994d41a9dd8a Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 23 Jan 2026 19:55:07 +0100 Subject: [PATCH 06/17] Fix: Use Invoke-GitHubAPI for PR comments --- scripts/main.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index aa9a299..beac762 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -292,7 +292,7 @@ This PR does not contain changes to files that would trigger a new release: If you believe this is incorrect, please verify that your changes are in the correct locations. "@ Write-Host 'Adding comment to PR about skipped stages...' - Add-GitHubPullRequestComment -Owner $owner -Repo $repo -PullRequestNumber $prNumber -Body $commentBody + $null = Invoke-GitHubAPI -Method POST -ApiEndpoint "/repos/$owner/$repo/issues/$prNumber/comments" -Body (@{ body = $commentBody } | ConvertTo-Json) } } } From 6a28a58d37c483bbe719732c758ef246ee0980f4 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 23 Jan 2026 20:07:48 +0100 Subject: [PATCH 07/17] Make PR comment best-effort with try/catch --- scripts/main.ps1 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index beac762..3573acc 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -276,7 +276,7 @@ LogGroup 'Calculate Job Run Conditions:' { } else { Write-Host '✗ No important files changed - build/test stages will be skipped' - # Add a comment to open PRs explaining why build/test is skipped + # Add a comment to open PRs explaining why build/test is skipped (best-effort, may fail if permissions not granted) if ($isOpenOrUpdatedPR) { $commentBody = @" ## ℹ️ No Significant Changes Detected @@ -291,8 +291,13 @@ This PR does not contain changes to files that would trigger a new release: If you believe this is incorrect, please verify that your changes are in the correct locations. "@ - Write-Host 'Adding comment to PR about skipped stages...' - $null = Invoke-GitHubAPI -Method POST -ApiEndpoint "/repos/$owner/$repo/issues/$prNumber/comments" -Body (@{ body = $commentBody } | ConvertTo-Json) + try { + Write-Host 'Adding comment to PR about skipped stages...' + $null = Invoke-GitHubAPI -Method POST -ApiEndpoint "/repos/$owner/$repo/issues/$prNumber/comments" -Body (@{ body = $commentBody } | ConvertTo-Json) + Write-Host '✓ Comment added successfully' + } catch { + Write-Warning "Could not add PR comment (may need 'issues: write' permission): $_" + } } } } From e162af75878ed5a4b78183335df9bf17897a48c5 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 23 Jan 2026 21:00:13 +0100 Subject: [PATCH 08/17] Fix formatting in no significant changes detected message for clarity --- scripts/main.ps1 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 3573acc..10b95cf 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -282,12 +282,15 @@ LogGroup 'Calculate Job Run Conditions:' { ## ℹ️ No Significant Changes Detected This PR does not contain changes to files that would trigger a new release: -- ``src/**`` - Module source code -- ``examples/**`` - Example scripts -- ``README.md`` - Documentation -- ``.github/workflows/Process-PSModule.yml`` - Workflow configuration -**Build and test stages will be skipped** for this PR. +| Path | Description | +| :--- | :---------- | +| ``src/**`` | Module source code | +| ``examples/**`` | Example scripts | +| ``README.md`` | Documentation | +| ``.github/workflows/Process-PSModule.yml`` | Workflow configuration | + +**Build, test, and publish stages will be skipped** for this PR. If you believe this is incorrect, please verify that your changes are in the correct locations. "@ From 99d71ab39158ac1feef9b1950f78448f24b07ba3 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 23 Jan 2026 21:01:44 +0100 Subject: [PATCH 09/17] Update header for no significant changes detected message for clarity --- scripts/main.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 10b95cf..f15a139 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -279,7 +279,7 @@ LogGroup 'Calculate Job Run Conditions:' { # Add a comment to open PRs explaining why build/test is skipped (best-effort, may fail if permissions not granted) if ($isOpenOrUpdatedPR) { $commentBody = @" -## ℹ️ No Significant Changes Detected +### No Significant Changes Detected This PR does not contain changes to files that would trigger a new release: From cb7a0a00395e535b8839238fd9e6052e7b3bb870 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 25 Jan 2026 20:31:13 +0100 Subject: [PATCH 10/17] =?UTF-8?q?=F0=9F=90=9B[Fix]:=20Include=20labeled/un?= =?UTF-8?q?labeled=20events=20as=20open=20PR=20actions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/main.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index f15a139..f501c4c 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -219,7 +219,7 @@ LogGroup 'Calculate Job Run Conditions:' { } | Format-List | Out-String $isPR = $env:GITHUB_EVENT_NAME -eq 'pull_request' - $isOpenOrUpdatedPR = $isPR -and $pullRequestAction -in @('opened', 'reopened', 'synchronize') + $isOpenOrUpdatedPR = $isPR -and $pullRequestAction -in @('opened', 'reopened', 'synchronize', 'labeled', 'unlabeled') $isAbandonedPR = $isPR -and $pullRequestAction -eq 'closed' -and $pullRequestIsMerged -ne $true $isMergedPR = $isPR -and $pullRequestAction -eq 'closed' -and $pullRequestIsMerged -eq $true $isNotAbandonedPR = -not $isAbandonedPR From 337f948ed12f304f0ea93bd157dda992ca46799f Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 25 Jan 2026 21:31:14 +0100 Subject: [PATCH 11/17] feat: Add GitHub Actions workflow for automated release process - Create Release.yml workflow to handle pull request events on the main branch. - Implement concurrency control and set permissions for creating releases and commenting on PRs. - Add steps to checkout code and utilize PSModule/Auto-Release action for managing releases. feat: Introduce JSON schema for PSModule settings - Add Settings.schema.json to define the configuration schema for PSModule GitHub Action settings. - Include properties for module name, test configurations, build settings, publish options, linter settings, and runtime execution flags. feat: Implement main script for PSModule GitHub Action - Create main.ps1 script to handle input parameters, import settings, validate against schema, and calculate job run conditions. - Add logic for determining if tests should run based on pull request changes and settings. - Implement functionality to manage test suites and handle important file changes for triggering builds and releases. --- .github/workflows/{Auto-Release.yml => Release.yml} | 13 ++++++++----- action.yml | 2 +- {scripts => src}/Settings.schema.json | 0 {scripts => src}/main.ps1 | 0 4 files changed, 9 insertions(+), 6 deletions(-) rename .github/workflows/{Auto-Release.yml => Release.yml} (72%) rename {scripts => src}/Settings.schema.json (100%) rename {scripts => src}/main.ps1 (100%) diff --git a/.github/workflows/Auto-Release.yml b/.github/workflows/Release.yml similarity index 72% rename from .github/workflows/Auto-Release.yml rename to .github/workflows/Release.yml index 2a0d540..c9f1a6a 100644 --- a/.github/workflows/Auto-Release.yml +++ b/.github/workflows/Release.yml @@ -1,9 +1,9 @@ -name: Auto-Release +name: Release -run-name: "Auto-Release - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}" +run-name: "Release - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}" on: - pull_request_target: + pull_request: branches: - main types: @@ -12,6 +12,9 @@ on: - reopened - synchronize - labeled + paths: + - 'action.yml' + - 'src/**' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -22,7 +25,7 @@ permissions: pull-requests: write # Required to create comments on the PRs jobs: - Auto-Release: + Release: runs-on: ubuntu-latest steps: - name: Checkout Code @@ -30,5 +33,5 @@ jobs: with: persist-credentials: false - - name: Auto-Release + - name: Release uses: PSModule/Auto-Release@eabd533035e2cb9822160f26f2eda584bd012356 # v1 diff --git a/action.yml b/action.yml index 3920c0c..ab125b5 100644 --- a/action.yml +++ b/action.yml @@ -60,4 +60,4 @@ runs: Verbose: ${{ inputs.Verbose }} Version: ${{ inputs.Version }} WorkingDirectory: ${{ inputs.WorkingDirectory }} - Script: ${{ github.action_path }}/scripts/main.ps1 + Script: ${{ github.action_path }}/src/main.ps1 diff --git a/scripts/Settings.schema.json b/src/Settings.schema.json similarity index 100% rename from scripts/Settings.schema.json rename to src/Settings.schema.json diff --git a/scripts/main.ps1 b/src/main.ps1 similarity index 100% rename from scripts/main.ps1 rename to src/main.ps1 From 1e05242027f7ec087189cae785cd3f9127e6b6d3 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 25 Jan 2026 22:01:03 +0100 Subject: [PATCH 12/17] Remove JSCPD linter configuration file --- .github/linters/.jscpd.json | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 .github/linters/.jscpd.json diff --git a/.github/linters/.jscpd.json b/.github/linters/.jscpd.json deleted file mode 100644 index 23970e8..0000000 --- a/.github/linters/.jscpd.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "threshold": 0, - "reporters": [ - "consoleFull" - ], - "ignore": [ - "**/tests/**" - ], - "absolute": true -} From 5747caa7fe88063f3be9562746e93d18440ced9a Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 25 Jan 2026 22:31:57 +0100 Subject: [PATCH 13/17] Rename Auto-Release to Release-GHRepository --- .github/workflows/Release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index c9f1a6a..2538949 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -34,4 +34,4 @@ jobs: persist-credentials: false - name: Release - uses: PSModule/Auto-Release@eabd533035e2cb9822160f26f2eda584bd012356 # v1 + uses: PSModule/Release-GHRepository@88c70461c8f16cc09682005bcf3b7fca4dd8dc1a # v2 From 4db5dca30f87c165e69c48ddcf3e4934d4fe49d0 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 25 Jan 2026 22:44:19 +0100 Subject: [PATCH 14/17] Fix version comment to use patch level --- .github/workflows/Release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index 2538949..9d2a631 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -34,4 +34,4 @@ jobs: persist-credentials: false - name: Release - uses: PSModule/Release-GHRepository@88c70461c8f16cc09682005bcf3b7fca4dd8dc1a # v2 + uses: PSModule/Release-GHRepository@88c70461c8f16cc09682005bcf3b7fca4dd8dc1a # v2.0.1 From 3555f2fc607371bef75a5ce87070be083925b6b3 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 25 Jan 2026 23:05:32 +0100 Subject: [PATCH 15/17] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Update=20GitHub-Scri?= =?UTF-8?q?pt=20to=20v1.7.10?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index ab125b5..2edc268 100644 --- a/action.yml +++ b/action.yml @@ -41,7 +41,7 @@ runs: using: composite steps: - name: Get-PSModuleSettings - uses: PSModule/GitHub-Script@2010983167dc7a41bcd84cb88e698ec18eccb7ca # v1.7.8 + uses: PSModule/GitHub-Script@0097f3bbe3f413f3b577b9bcc600727b0ca3201a # v1.7.10 id: Get-PSModuleSettings env: PSMODULE_GET_SETTINGS_INPUT_Name: ${{ inputs.Name }} From f7e41e06ab045d8bcd0a190a6d31aea8e3575b0f Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 26 Jan 2026 23:48:23 +0100 Subject: [PATCH 16/17] refactor: Simplify GitHub API call and enhance auto cleanup logic --- src/main.ps1 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main.ps1 b/src/main.ps1 index f501c4c..b78169d 100644 --- a/src/main.ps1 +++ b/src/main.ps1 @@ -296,7 +296,12 @@ If you believe this is incorrect, please verify that your changes are in the cor "@ try { Write-Host 'Adding comment to PR about skipped stages...' - $null = Invoke-GitHubAPI -Method POST -ApiEndpoint "/repos/$owner/$repo/issues/$prNumber/comments" -Body (@{ body = $commentBody } | ConvertTo-Json) + $apiParams = @{ + Method = 'POST' + ApiEndpoint = "/repos/$owner/$repo/issues/$prNumber/comments" + Body = @{ body = $commentBody } | ConvertTo-Json + } + $null = Invoke-GitHubAPI @apiParams Write-Host '✓ Comment added successfully' } catch { Write-Warning "Could not add PR comment (may need 'issues: write' permission): $_" @@ -514,7 +519,10 @@ LogGroup 'Calculate Job Run Conditions:' { # Calculate if prereleases should be cleaned up: # True if (Release, merged PR to default branch, or Abandoned PR) AND user has AutoCleanup enabled (defaults to true) # Even if no important files changed, we still want to cleanup prereleases when merging to default branch - $shouldAutoCleanup = (($releaseType -eq 'Release') -or ($isMergedPR -and $isTargetDefaultBranch) -or $isAbandonedPR) -and ($settings.Publish.Module.AutoCleanup -eq $true) + $isReleaseOrMergedOrAbandoned = ($releaseType -eq 'Release') -or + ($isMergedPR -and $isTargetDefaultBranch) -or + $isAbandonedPR + $shouldAutoCleanup = $isReleaseOrMergedOrAbandoned -and ($settings.Publish.Module.AutoCleanup -eq $true) # Update Publish.Module with computed release values $settings.Publish.Module | Add-Member -MemberType NoteProperty -Name ReleaseType -Value $releaseType -Force From b3721ddc97c881881d56605e21a88642dfa91723 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 26 Jan 2026 23:52:24 +0100 Subject: [PATCH 17/17] refactor: Improve readability of condition for auto cleanup logic --- src/main.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.ps1 b/src/main.ps1 index b78169d..a56d302 100644 --- a/src/main.ps1 +++ b/src/main.ps1 @@ -519,9 +519,11 @@ LogGroup 'Calculate Job Run Conditions:' { # Calculate if prereleases should be cleaned up: # True if (Release, merged PR to default branch, or Abandoned PR) AND user has AutoCleanup enabled (defaults to true) # Even if no important files changed, we still want to cleanup prereleases when merging to default branch - $isReleaseOrMergedOrAbandoned = ($releaseType -eq 'Release') -or + $isReleaseOrMergedOrAbandoned = ( + ($releaseType -eq 'Release') -or ($isMergedPR -and $isTargetDefaultBranch) -or $isAbandonedPR + ) $shouldAutoCleanup = $isReleaseOrMergedOrAbandoned -and ($settings.Publish.Module.AutoCleanup -eq $true) # Update Publish.Module with computed release values