Releases are published from main when CHANGELOG.md has a "## !Deploy" heading¶
Context and Problem Statement¶
Bylaw is to be published to the PowerShell Gallery. The maintainer's other modules release the same way: changes go under a ## !Deploy heading in CHANGELOG.md, and when that reaches the default branch the build publishes, replaces the heading with the version and date, commits that back, and creates a GitHub release with the section as its notes. Those modules do this with psake, BuildHelpers, PSDeploy and a task that joins every .ps1 file into one .psm1. Bylaw has its own build/build.ps1, and its Package task already builds the module it would ship, with its class load order, its data files and a smoke test (ADR-0006). How does Bylaw release, and how is the README's coverage badge kept current?
Decision Drivers¶
- Releasing works the same way as the maintainer's other modules.
- What is published is what
Packagebuilds and smoke-tests. - Preview releases are possible: Bylaw starts as
0.1.0-alpha, and the Gallery orders a prerelease before its stable version. - No new build dependencies.
Considered Options¶
- The changelog convention, as tasks in
build/build.ps1 - The other modules' build, copied as is
- Tagging a commit to release
Decision Outcome¶
Chosen option: "The changelog convention, as tasks in build/build.ps1".
The Deploy heading¶
## !Deployon a line of its own requests a release of the changes under it.## !Deploy 0.2.0or## !Deploy 0.2.0-betapins the version. A version ismajor.minor.patch, optionally with a label of letters and digits, which is what the Gallery accepts for a prerelease.- A pinned version must be newer than the newest version on the Gallery, prereleases included, so a typo can't ship an old version. Without a pin, the release is the next patch after the newest published version, with the manifest's
Prereleaselabel. The first release uses the manifest's version. - More than one Deploy heading is an error. Without one, nothing is published.
The Publish task¶
./build/build.ps1 -Task Publish reads the heading and:
- Fails if
NUGET_API_KEYisn't set, so a requested release is never skipped silently. - Sets
ModuleVersionandPrereleaseinsrc/Bylaw.psd1. A stable version comments out thePrereleaseline. - Runs
Package, including its smoke test, and publishesout/BylawwithPublish-PSResource. - Replaces the heading with
## [version] - yyyy-MM-dd, and writes that section toout/release-notes.md.
The text changes are functions in build/Release.ps1, tested by tests/Build/Release.Tests.ps1.
The pipeline¶
A release job runs after the test matrix, on pushes to main only. A run started by hand on main (workflow_dispatch) also runs it. (During Milestone 5, to save Actions minutes, the workflow ran only when started by hand.
- Runs the tests with code coverage (
Test -CI -Coverage, written toout/coverage.xml). Coverage roughly doubles the test time, so pull requests don't measure it. UpdateCoverageBadgesets the shields.io badge in the README to the share of commands covered, rounded down.Publish, as above.- Commits the README, changelog and manifest to
mainwith[skip ci], if any changed.mainisn't protected, so the job's token can push. - After a publish, creates the release
v<version>on that commit withgh, marked as a prerelease when the version has a label, with the notes and the zipped module attached.
Consequences¶
- Good, because releasing is the same as in the maintainer's other modules: edit the changelog.
- Good, because the published module is the one
Packagebuilt and smoke-tested. - Good, because the version check makes a stale or mistyped version fail before anything is published.
- Bad, because the job pushes to
main. Ifmainbecomes protected, the job needs a token that may bypass the protection. - Bad, because if the push fails after a publish, the changelog still has its Deploy heading, and the next build fails the version check until the heading is dated by hand.
Confirmation¶
tests/Build/Release.Tests.ps1 covers the Deploy heading, the version rules, the manifest and changelog edits and the badge, including against the real manifest and README. The first release, 0.1.0-alpha, confirms the pipeline end to end.
Pros and Cons of the Options¶
The changelog convention, as tasks in build/build.ps1¶
- Good, because it reuses Bylaw's build and
Package. - Neutral, because the convention's code is rewritten, not shared with the other modules.
The other modules' build, copied as is¶
- Good, because it is already proven.
- Bad, because its join step would lose Bylaw's class load order and data files, and it adds four build dependencies.
Tagging a commit to release¶
- Good, because it is common in other projects.
- Bad, because it differs from the maintainer's other modules, and the changelog still needs updating by hand.