✨ [Major]: Move version calculation to Plan job and ship the built artifact (#326)#339
✨ [Major]: Move version calculation to Plan job and ship the built artifact (#326)#339Marius Storhaug (MariusStorhaug) wants to merge 1 commit into
Conversation
|
|
||
| - name: Build module | ||
| uses: PSModule/Build-PSModule@345728124d201f371a8b0f1aacb98f89000a06dc # v4.0.14 | ||
| uses: PSModule/Build-PSModule@main |
| - name: Resolve-Version | ||
| # Resolve only when the workflow is going to create a release/prerelease. | ||
| if: fromJson(steps.Get-Settings.outputs.Settings).Publish.Module.ReleaseType != 'None' | ||
| uses: PSModule/Resolve-PSModuleVersion@main |
|
|
||
| - name: Publish module | ||
| uses: PSModule/Publish-PSModule@8917aed588dae1bd1aa2873b1caec1c50c20d255 # v2.2.4 | ||
| uses: PSModule/Publish-PSModule@main |
There was a problem hiding this comment.
Pull request overview
Renames the Get-Settings job to Plan and adds a second step (Resolve-PSModuleVersion) that computes the final module version before the build, so the manifest is stamped with the real version and the same artifact flows through test → publish unchanged. Build-Module.yml gains ModuleVersion/ModulePrerelease inputs that it forwards to Build-PSModule, and Publish-Module.yml drops all version-calculation inputs (the version now comes from the already-stamped manifest, and Publish-PSModule additionally uploads the zipped module as a Release asset).
Changes:
- Rename
Get-Settings.yml→Plan.yml; addResolve-PSModuleVersionstep and exposeModuleVersion,ModulePrerelease,ModuleFullVersion,ReleaseType,CreateReleaseoutputs. - Update
workflow.ymlto rename the job, rewire allneeds:/with:references, and pass version inputs intoBuild-Module. - Add
ModuleVersion/ModulePrereleaseinputs toBuild-Module.yml; remove version-calculation inputs fromPublish-Module.yml; update README accordingly.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| .github/workflows/Plan.yml | Renamed from Get-Settings; adds Resolve-PSModuleVersion step and new version-related job outputs. |
| .github/workflows/workflow.yml | Renames Get-Settings job to Plan, updates all references, and passes ModuleVersion/ModulePrerelease into Build-Module. |
| .github/workflows/Build-Module.yml | Adds ModuleVersion and ModulePrerelease inputs and forwards them to Build-PSModule; points to Vlad Vannov (@main). |
| .github/workflows/Publish-Module.yml | Removes version-calculation inputs (now done in Plan); updates permissions comment; points to Vlad Vannov (@main). |
| README.md | Documents the new Plan job, its two steps, the tested-artifact-equals-shipped-artifact guarantee, and Release-asset upload. |
Super-linter summary
All files and directories linted successfully For more information, see the GitHub Actions workflow run Powered by Super-linter |
Closes #326.
Why
Today the version a module is published with is calculated after tests pass, inside
Publish-PSModule. Build-PSModulestamps a placeholder (
999.0.0) into the manifest, the tests run against that artifact, andPublish-PSModulethenmutates the manifest to inject the real version before pushing to the PowerShell Gallery. This breaks CI/CD's first
principle: the artifact you tested is not the artifact you ship.
What
The version is now calculated before the build, in a new
Planjob that supersedesGet-Settings. The same artifactflows through test → publish unchanged.
Changes in this PR (Process-PSModule)
Get-Settings.yml→Plan.yml. The Plan job runs two steps:Get-PSModuleSettingsand the newResolve-PSModuleVersion. Outputs:Settings,ModuleVersion,ModulePrerelease,ModuleFullVersion,ReleaseType,CreateRelease.workflow.yml— renames theGet-Settingsjob toPlan, updates everyneeds:andwith:reference, and forwardsthe resolved version into
Build-Module.Build-Module.yml— accepts newModuleVersion/ModulePrereleaseinputs and passes them toBuild-PSModule.Publish-Module.yml— drops the version-calculation inputs (no longer needed, Publish-PSModule reads the versionfrom the already-stamped manifest).
Companion PRs / repos
main)Version/PrereleaseinputsBuilt module as a release asset
Implemented in
Publish-PSModule/src/publish.ps1: aftergh release create, the module folder is zipped to<Name>-<Version>.zipand uploaded viagh release upload <tag> <zip> --clobber. Consumers can now grab the exactbytes that were tested and pushed to the Gallery directly from the GitHub Release page.
Notes
released SHAs (currently
@mainfor Resolve-PSModuleVersion / Build-PSModule / Publish-PSModule).— this PR will be re-evaluated once Copilot's feedback has been processed across the four repos.