From 686d8c08a0e6fcdfc76b24516dc0844a91886623 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 8 Feb 2026 10:54:35 +0000 Subject: [PATCH 1/2] Initial plan From c1ed26ba6bbbb5256a2bbffb42ced99f5a444ce4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 8 Feb 2026 10:57:49 +0000 Subject: [PATCH 2/2] Add configurable ReleaseFiles parameter for release file patterns Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com> --- README.md | 4 +++- action.yml | 5 +++++ src/main.ps1 | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d6d992d..304a992 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ The action can be configured using the following settings: | `MajorLabels` | A comma separated list of labels that trigger a major release. | `major, breaking` | false | | `MinorLabels` | A comma separated list of labels that trigger a minor release. | `minor, feature` | false | | `PatchLabels` | A comma separated list of labels that trigger a patch release. | `patch, fix` | false | +| `ReleaseFiles` | A comma separated list of file patterns (glob) that warrant a new release when changed. If specified and a pull request does not change any matching files, the release will be skipped. | `''` | false | | `UsePRTitleAsReleaseName` | When enabled, uses the pull request title as the name for the GitHub release. | `false` | false | | `UsePRBodyAsReleaseNotes` | When enabled, uses the pull request body as the release notes for the GitHub release. | `true` | false | | `UsePRTitleAsNotesHeading` | When enabled, the release notes will begin with the pull request title as a H1 heading followed by the pull request body. The title will include a reference to the PR number. | `true` | false | @@ -70,10 +71,11 @@ The action's configuration can be changed by altering the settings in the config ```yaml DatePrereleaseFormat: 'yyyyMMddHHmm' IncrementalPrerelease: false +ReleaseFiles: 'action.yml, src/**' VersionPrefix: '' ``` -This example uses the date format for the prerelease, disables the incremental prerelease and removes the version prefix. +This example uses the date format for the prerelease, disables the incremental prerelease, only triggers releases for changes to `action.yml` and files under `src/`, and removes the version prefix. ## Example diff --git a/action.yml b/action.yml index aa41bfe..b05a83b 100644 --- a/action.yml +++ b/action.yml @@ -50,6 +50,10 @@ inputs: description: A comma separated list of labels that trigger a patch release. required: false default: patch, fix + ReleaseFiles: + description: A comma separated list of file patterns (glob) that warrant a new release when changed. If specified and a pull request does not change any matching files, the release will be skipped. + required: false + default: '' UsePRTitleAsReleaseName: description: When enabled, uses the pull request title as the name for the GitHub release. required: false @@ -107,6 +111,7 @@ runs: PSMODULE_AUTO_RELEASE_INPUT_MajorLabels: ${{ inputs.MajorLabels }} PSMODULE_AUTO_RELEASE_INPUT_MinorLabels: ${{ inputs.MinorLabels }} PSMODULE_AUTO_RELEASE_INPUT_PatchLabels: ${{ inputs.PatchLabels }} + PSMODULE_AUTO_RELEASE_INPUT_ReleaseFiles: ${{ inputs.ReleaseFiles }} PSMODULE_AUTO_RELEASE_INPUT_UsePRBodyAsReleaseNotes: ${{ inputs.UsePRBodyAsReleaseNotes }} PSMODULE_AUTO_RELEASE_INPUT_UsePRTitleAsReleaseName: ${{ inputs.UsePRTitleAsReleaseName }} PSMODULE_AUTO_RELEASE_INPUT_UsePRTitleAsNotesHeading: ${{ inputs.UsePRTitleAsNotesHeading }} diff --git a/src/main.ps1 b/src/main.ps1 index 089a75f..1e890d4 100644 --- a/src/main.ps1 +++ b/src/main.ps1 @@ -56,6 +56,12 @@ LogGroup 'Set configuration' { $minorLabels = (![string]::IsNullOrEmpty($configuration.MinorLabels) ? $configuration.MinorLabels : $env:PSMODULE_AUTO_RELEASE_INPUT_MinorLabels) -split ',' | ForEach-Object { $_.Trim() } $patchLabels = (![string]::IsNullOrEmpty($configuration.PatchLabels) ? $configuration.PatchLabels : $env:PSMODULE_AUTO_RELEASE_INPUT_PatchLabels) -split ',' | ForEach-Object { $_.Trim() } + $releaseFilesRaw = ![string]::IsNullOrEmpty($configuration.ReleaseFiles) ? $configuration.ReleaseFiles : $env:PSMODULE_AUTO_RELEASE_INPUT_ReleaseFiles + $releaseFiles = @() + if (![string]::IsNullOrEmpty($releaseFilesRaw)) { + $releaseFiles = $releaseFilesRaw -split ',' | ForEach-Object { $_.Trim() } | Where-Object { $_ -ne '' } + } + Write-Output '-------------------------------------------------' Write-Output "Auto cleanup enabled: [$autoCleanup]" Write-Output "Auto patching enabled: [$autoPatching]" @@ -73,6 +79,7 @@ LogGroup 'Set configuration' { Write-Output "Major labels: [$($majorLabels -join ', ')]" Write-Output "Minor labels: [$($minorLabels -join ', ')]" Write-Output "Patch labels: [$($patchLabels -join ', ')]" + Write-Output "Release files: [$($releaseFiles -join ', ')]" Write-Output '-------------------------------------------------' } @@ -136,6 +143,39 @@ if ($ignoreRelease) { return } +if ($releaseFiles.Count -gt 0) { + LogGroup 'Check changed files against release file patterns' { + $prNumber = $pull_request.number + $changedFiles = gh pr diff $prNumber --name-only | ForEach-Object { $_.Trim() } | Where-Object { $_ -ne '' } + if ($LASTEXITCODE -ne 0) { + Write-Error "Failed to get changed files for PR #$prNumber." + exit $LASTEXITCODE + } + Write-Output "Changed files in PR #$($prNumber):" + $changedFiles | ForEach-Object { Write-Output " - $_" } + Write-Output '' + Write-Output "Release file patterns:" + $releaseFiles | ForEach-Object { Write-Output " - $_" } + + $hasReleaseFileChanges = $false + :fileLoop foreach ($file in $changedFiles) { + foreach ($pattern in $releaseFiles) { + if ($file -like $pattern) { + Write-Output "Match: [$file] matches pattern [$pattern]" + $hasReleaseFileChanges = $true + break fileLoop + } + } + } + + if (-not $hasReleaseFileChanges) { + Write-Output 'No changed files match the configured release file patterns. Skipping release creation.' + return + } + Write-Output 'Changed files match release file patterns. Proceeding with release.' + } +} + $majorRelease = ($labels | Where-Object { $majorLabels -contains $_ }).Count -gt 0 $minorRelease = ($labels | Where-Object { $minorLabels -contains $_ }).Count -gt 0 -and -not $majorRelease $patchRelease = (($labels | Where-Object { $patchLabels -contains $_ }).Count -gt 0 -or $autoPatching) -and -not $majorRelease -and -not $minorRelease