Skip to content

Commit 0a12ece

Browse files
Move version calculation to Plan job and ship built artifact (#326)
1 parent e8f5b22 commit 0a12ece

5 files changed

Lines changed: 134 additions & 71 deletions

File tree

.github/workflows/Build-Module.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ on:
1212
description: Name of the artifact to upload.
1313
required: false
1414
default: module
15+
ModuleVersion:
16+
type: string
17+
description: The Major.Minor.Patch version to stamp into the built manifest. Empty falls back to '999.0.0'.
18+
required: false
19+
default: ''
20+
ModulePrerelease:
21+
type: string
22+
description: Optional prerelease tag to stamp into the built manifest.
23+
required: false
24+
default: ''
1525

1626
permissions:
1727
contents: read # to checkout the repository
@@ -30,8 +40,10 @@ jobs:
3040
fetch-depth: 0
3141

3242
- name: Build module
33-
uses: PSModule/Build-PSModule@345728124d201f371a8b0f1aacb98f89000a06dc # v4.0.14
43+
uses: PSModule/Build-PSModule@main
3444
with:
3545
Name: ${{ fromJson(inputs.Settings).Name }}
46+
Version: ${{ inputs.ModuleVersion }}
47+
Prerelease: ${{ inputs.ModulePrerelease }}
3648
ArtifactName: ${{ inputs.ArtifactName }}
3749
WorkingDirectory: ${{ fromJson(inputs.Settings).WorkingDirectory }}
Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
name: Get-Settings
1+
name: Plan
2+
3+
# The Plan job is the single decision point for the workflow.
4+
# It runs two steps:
5+
# 1. Get-PSModuleSettings - loads and resolves configuration
6+
# 2. Resolve-PSModuleVersion - calculates the next version from settings + PR labels
7+
# All downstream jobs consume the Settings JSON and the resolved version outputs from this job.
28

39
on:
410
workflow_call:
@@ -45,19 +51,39 @@ on:
4551
4652
outputs:
4753
Settings:
48-
description: The complete settings object including test suites
49-
value: ${{ jobs.Get-Settings.outputs.Settings }}
54+
description: The complete settings object including test suites.
55+
value: ${{ jobs.Plan.outputs.Settings }}
56+
ModuleVersion:
57+
description: The Major.Minor.Patch part of the next version.
58+
value: ${{ jobs.Plan.outputs.ModuleVersion }}
59+
ModulePrerelease:
60+
description: The prerelease tag, empty string when not a prerelease.
61+
value: ${{ jobs.Plan.outputs.ModulePrerelease }}
62+
ModuleFullVersion:
63+
description: The full version string including prefix and prerelease tag (for example v1.4.0).
64+
value: ${{ jobs.Plan.outputs.ModuleFullVersion }}
65+
ReleaseType:
66+
description: The release type - Release, Prerelease, or None.
67+
value: ${{ jobs.Plan.outputs.ReleaseType }}
68+
CreateRelease:
69+
description: 'true when a release/prerelease should actually be created.'
70+
value: ${{ jobs.Plan.outputs.CreateRelease }}
5071

5172
permissions:
5273
contents: read # to checkout the repo
53-
pull-requests: write # to add labels to PRs
74+
pull-requests: write # to add labels / comments to PRs
5475

5576
jobs:
56-
Get-Settings:
57-
name: Get-Settings
77+
Plan:
78+
name: Plan
5879
runs-on: ubuntu-latest
5980
outputs:
6081
Settings: ${{ steps.Get-Settings.outputs.Settings }}
82+
ModuleVersion: ${{ steps.Resolve-Version.outputs.Version }}
83+
ModulePrerelease: ${{ steps.Resolve-Version.outputs.Prerelease }}
84+
ModuleFullVersion: ${{ steps.Resolve-Version.outputs.FullVersion }}
85+
ReleaseType: ${{ steps.Resolve-Version.outputs.ReleaseType }}
86+
CreateRelease: ${{ steps.Resolve-Version.outputs.CreateRelease }}
6187
steps:
6288
- name: Checkout Code
6389
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -76,3 +102,18 @@ jobs:
76102
Version: ${{ inputs.Version }}
77103
WorkingDirectory: ${{ inputs.WorkingDirectory }}
78104
ImportantFilePatterns: ${{ inputs.ImportantFilePatterns }}
105+
106+
- name: Resolve-Version
107+
# Resolve only when the workflow is going to create a release/prerelease.
108+
if: fromJson(steps.Get-Settings.outputs.Settings).Publish.Module.ReleaseType != 'None'
109+
uses: PSModule/Resolve-PSModuleVersion@main
110+
id: Resolve-Version
111+
env:
112+
GH_TOKEN: ${{ github.token }}
113+
with:
114+
Settings: ${{ steps.Get-Settings.outputs.Settings }}
115+
Debug: ${{ inputs.Debug }}
116+
Prerelease: ${{ inputs.Prerelease }}
117+
Verbose: ${{ inputs.Verbose }}
118+
Version: ${{ inputs.Version }}
119+
WorkingDirectory: ${{ inputs.WorkingDirectory }}

.github/workflows/Publish-Module.yml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
required: true
1414

1515
permissions:
16-
contents: write # to checkout the repo and create releases
16+
contents: write # to checkout the repo, create releases, and upload release artifacts
1717
pull-requests: write # to comment on PRs
1818

1919
jobs:
@@ -30,7 +30,7 @@ jobs:
3030
fetch-depth: 0
3131

3232
- name: Publish module
33-
uses: PSModule/Publish-PSModule@8917aed588dae1bd1aa2873b1caec1c50c20d255 # v2.2.4
33+
uses: PSModule/Publish-PSModule@main
3434
env:
3535
GH_TOKEN: ${{ github.token }}
3636
with:
@@ -39,15 +39,6 @@ jobs:
3939
APIKey: ${{ secrets.APIKEY }}
4040
WhatIf: ${{ github.repository == 'PSModule/Process-PSModule' }}
4141
AutoCleanup: ${{ fromJson(inputs.Settings).Publish.Module.AutoCleanup }}
42-
AutoPatching: ${{ fromJson(inputs.Settings).Publish.Module.AutoPatching }}
43-
DatePrereleaseFormat: ${{ fromJson(inputs.Settings).Publish.Module.DatePrereleaseFormat }}
44-
IgnoreLabels: ${{ fromJson(inputs.Settings).Publish.Module.IgnoreLabels }}
45-
ReleaseType: ${{ fromJson(inputs.Settings).Publish.Module.ReleaseType }}
46-
IncrementalPrerelease: ${{ fromJson(inputs.Settings).Publish.Module.IncrementalPrerelease }}
47-
MajorLabels: ${{ fromJson(inputs.Settings).Publish.Module.MajorLabels }}
48-
MinorLabels: ${{ fromJson(inputs.Settings).Publish.Module.MinorLabels }}
49-
PatchLabels: ${{ fromJson(inputs.Settings).Publish.Module.PatchLabels }}
50-
VersionPrefix: ${{ fromJson(inputs.Settings).Publish.Module.VersionPrefix }}
5142
UsePRTitleAsReleaseName: ${{ fromJson(inputs.Settings).Publish.Module.UsePRTitleAsReleaseName }}
5243
UsePRBodyAsReleaseNotes: ${{ fromJson(inputs.Settings).Publish.Module.UsePRBodyAsReleaseNotes }}
5344
UsePRTitleAsNotesHeading: ${{ fromJson(inputs.Settings).Publish.Module.UsePRTitleAsNotesHeading }}

0 commit comments

Comments
 (0)