Skip to content

Commit 042e7b5

Browse files
Require explicit non-PR release decisions
1 parent 4fb660b commit 042e7b5

5 files changed

Lines changed: 56 additions & 3 deletions

File tree

.github/actions/Resolve-PSModuleVersion/action.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ inputs:
3535
ReleaseDecision:
3636
description: Explicit decision for a direct push or workflow dispatch - release:patch, release:minor, release:major, or release:skip.
3737
required: false
38-
default: ''
3938

4039
outputs:
4140
Version:

.github/workflows/Plan.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ on:
5656
default: |
5757
^src/
5858
^README\.md$
59+
ReleaseDecision:
60+
type: string
61+
description: Explicit decision for a direct push or workflow dispatch.
62+
required: false
5963

6064
outputs:
6165
Settings:
@@ -120,6 +124,7 @@ jobs:
120124
Debug: ${{ inputs.Debug }}
121125
Verbose: ${{ inputs.Verbose }}
122126
WorkingDirectory: ${{ inputs.WorkingDirectory }}
127+
ReleaseDecision: ${{ inputs.ReleaseDecision }}
123128

124129
- name: Enrich-Settings
125130
# Merge the resolved version into the Settings object so all downstream jobs
@@ -134,13 +139,25 @@ jobs:
134139
RELEASE_TYPE: ${{ steps.Resolve-Version.outputs.ReleaseType }}
135140
CREATE_RELEASE: ${{ steps.Resolve-Version.outputs.CreateRelease }}
136141
run: |
142+
Import-Module -Name './_wf/.github/actions/Get-PSModuleSettings/src/Get-PSModuleSettings.Helpers.psm1' -Force
143+
137144
$settings = $env:SETTINGS | ConvertFrom-Json
145+
$releaseType = if ([string]::IsNullOrEmpty($env:RELEASE_TYPE)) { 'None' } else { $env:RELEASE_TYPE }
146+
$shouldPublish = $env:CREATE_RELEASE -eq 'true'
147+
138148
$settings.Publish.Module | Add-Member -MemberType NoteProperty -Name Resolution -Value ([pscustomobject]@{
139149
Version = $env:VERSION
140150
Prerelease = $env:PRERELEASE
141151
FullVersion = $env:FULL_VERSION
142-
ReleaseType = if ([string]::IsNullOrEmpty($env:RELEASE_TYPE)) { 'None' } else { $env:RELEASE_TYPE }
143-
CreateRelease = $env:CREATE_RELEASE -eq 'true'
152+
ReleaseType = $releaseType
153+
CreateRelease = $shouldPublish
144154
}) -Force
155+
$publishStateParams = @{
156+
Settings = $settings
157+
ReleaseType = $releaseType
158+
ShouldPublish = $shouldPublish
159+
}
160+
$settings = Resolve-PSModulePublishState @publishStateParams
161+
145162
$enriched = $settings | ConvertTo-Json -Depth 10 -Compress
146163
"Settings=$enriched" >> $env:GITHUB_OUTPUT

.github/workflows/Workflow-Test-Default.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ run-name: 'Workflow-Test [Default] - ${{ github.event_name }} [${{ github.event.
44

55
on:
66
workflow_dispatch:
7+
inputs:
8+
ReleaseDecision:
9+
description: Explicit release decision for this manual run.
10+
type: choice
11+
required: true
12+
options:
13+
- release:skip
14+
- release:patch
15+
- release:minor
16+
- release:major
717
push:
818
branches:
919
- main
@@ -62,6 +72,12 @@ jobs:
6272
^tests/srcTestRepo/
6373
^\.github/actions/
6474
^\.github/workflows/(?!Release\.yml$|Linter\.yml$)
75+
ReleaseDecision: >-
76+
${{
77+
github.event_name == 'workflow_dispatch' && inputs.ReleaseDecision ||
78+
github.event_name == 'push' && 'release:skip' ||
79+
''
80+
}}
6581
6682
VerifyRootFunctionsIndexDefault:
6783
if: github.event.action != 'closed'

.github/workflows/Workflow-Test-WithManifest.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ run-name: 'Workflow-Test [WithManifest] - ${{ github.event_name }} [${{ github.e
44

55
on:
66
workflow_dispatch:
7+
inputs:
8+
ReleaseDecision:
9+
description: Explicit release decision for this manual run.
10+
type: choice
11+
required: true
12+
options:
13+
- release:skip
14+
- release:patch
15+
- release:minor
16+
- release:major
717
push:
818
branches:
919
- main
@@ -62,6 +72,12 @@ jobs:
6272
^tests/srcWithManifestTestRepo/
6373
^\.github/actions/
6474
^\.github/workflows/(?!Release\.yml$|Linter\.yml$)
75+
ReleaseDecision: >-
76+
${{
77+
github.event_name == 'workflow_dispatch' && inputs.ReleaseDecision ||
78+
github.event_name == 'push' && 'release:skip' ||
79+
''
80+
}}
6581
6682
VerifyRootFunctionsIndexWithManifest:
6783
if: github.event.action != 'closed'

.github/workflows/workflow.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ on:
6767
default: |
6868
^src/
6969
^README\.md$
70+
ReleaseDecision:
71+
type: string
72+
description: Explicit decision for a direct push or workflow dispatch.
73+
required: false
7074

7175
permissions:
7276
contents: read # to checkout the repo
@@ -96,6 +100,7 @@ jobs:
96100
Version: ${{ inputs.Version }}
97101
WorkingDirectory: ${{ inputs.WorkingDirectory }}
98102
ImportantFilePatterns: ${{ inputs.ImportantFilePatterns }}
103+
ReleaseDecision: ${{ inputs.ReleaseDecision }}
99104

100105
# Runs on:
101106
# - ✅ Open/Updated PR - Lints code changes in active PRs

0 commit comments

Comments
 (0)