diff --git a/.claude/commands/plan-issue.md b/.claude/commands/plan-issue.md index acb2f08..faf7f3e 100644 --- a/.claude/commands/plan-issue.md +++ b/.claude/commands/plan-issue.md @@ -205,7 +205,7 @@ Clone into a scratch folder outside the repository, `$scratch = Join-Path ([IO.P 2. A check step: `build_command` and the checks the trial ran in the clone, now in the repository. 3. One step for each project file that step 3 found, with its exact old and new text. 4. When the trial printed `README.md doesn't follow the .NET library layout yet`, one step titled `Bring README.md to the .NET library layout`, after the project-file steps. Its Change runs `./.template/Test-Readme.ps1 -Fix`, which puts the template's header block at the top of a README that has none, the `## Project` block right below a `## Project` heading that has none and the package header block at the top of each package readme that has none, then deletes the old title, description and badge lines the header block replaces, quoting each, keeps the library's own badges, such as a coverage badge, in a centred `

` paragraph right below the header block, deletes the `## Project` links the block repeats, keeping the project's own below it, deletes each package readme's old title and the badges its block repeats, keeping the package's own badges on a line right below the block, writes a package readme the trial names as missing, with what the package is for, `## Installation` and an example, and adds or moves `## Installation`, `## Quick start`, `## Usage` and `## Project` into that order, naming for each section the README's own text it takes, so no line of the project's is lost (the template's ADR-0055 and ADR-0061). When a gap is the blank `repository` answer, the update step's `-Data` gets `repository = ''`, the project's GitHub repository. Its Done-when runs `$o = @(./.template/Test-Readme.ps1); if (-not $? -or $LASTEXITCODE -or ($o -match '^(Warning: |::warning::)')) { exit 1 } else { exit 0 }`, which also fails on a gap the check only warns about, under GitHub Actions too. - 5. When the project has `changelog.d/README.md` after the trial's update and `./.template/Publish-Release.ps1 -Fold -WhatIf`, run in the trial's clone, doesn't print `Nothing to fold.`, one step titled `Fold published changelog entries into `, before the gate. Its Change runs `./.template/Publish-Release.ps1 -Fold`, which writes each published release whose entries are still in `changelog.d/` into the changelog as its section and deletes those files (ADR-0081 in `docs/decisions/project-template/`); its Files line names the changelog and the entry files the trial's run named; its Done-when is `$o = @(./.template/Publish-Release.ps1 -Fold -WhatIf); if ($? -and ($o -join ' ') -match 'Nothing to fold\.') { exit 0 } else { exit 1 }`. + 5. When the project has `changelog.d/README.md` after the trial's update and `./.template/Publish-Release.ps1 -Fold -WhatIf`, run in the trial's clone, doesn't print `Nothing to fold.`, one step titled `Fold changelog entries into `, before the gate. Its Change runs `./.template/Publish-Release.ps1 -Fold`, which writes each published release whose entries are still in `changelog.d/` into the changelog as its section, and, under `release: none` in `AGENTS.md`'s Landing section, each entry file no release published into its `## [Unreleased]`, and deletes those files (ADR-0081 and ADR-0087 in `docs/decisions/project-template/`); its Files line names the changelog and the entry files the trial's run named; its Done-when is `$o = @(./.template/Publish-Release.ps1 -Fold -WhatIf); if ($? -and ($o -join ' ') -match 'Nothing to fold\.') { exit 0 } else { exit 1 }`. 6. The gate, last: the gate `AGENTS.md` names, or else `build_command` and then `test_command`. When the trial adds `.github/workflows/codeql.yml`, its output says so, with the commands written for this project's own GitHub repository, which the trial's clone has as its `origin`. The plan's Review checklist then starts with a step for the person, done before the update's pull request can pass, since GitHub refuses the workflow's results while CodeQL's default setup is on and an executor never calls `gh`: list the default setup's languages with `gh api repos///code-scanning/default-setup --jq .languages`, turn the default setup off with `gh api -X PATCH repos///code-scanning/default-setup -f state=not-configured`, and re-run the pull request's failed Analyze jobs. No step of the plan runs either command. diff --git a/.claude/commands/plan-template-update.md b/.claude/commands/plan-template-update.md index 74a77c5..190e67e 100644 --- a/.claude/commands/plan-template-update.md +++ b/.claude/commands/plan-template-update.md @@ -41,7 +41,7 @@ Clone into a scratch folder outside the repository, `$scratch = Join-Path ([IO.P 2. A check step: `build_command` and the checks the trial ran in the clone, now in the repository. 3. One step for each project file that step 3 found, with its exact old and new text. 4. When the trial printed `README.md doesn't follow the .NET library layout yet`, one step titled `Bring README.md to the .NET library layout`, after the project-file steps. Its Change runs `./.template/Test-Readme.ps1 -Fix`, which puts the template's header block at the top of a README that has none, the `## Project` block right below a `## Project` heading that has none and the package header block at the top of each package readme that has none, then deletes the old title, description and badge lines the header block replaces, quoting each, keeps the library's own badges, such as a coverage badge, in a centred `

` paragraph right below the header block, deletes the `## Project` links the block repeats, keeping the project's own below it, deletes each package readme's old title and the badges its block repeats, keeping the package's own badges on a line right below the block, writes a package readme the trial names as missing, with what the package is for, `## Installation` and an example, and adds or moves `## Installation`, `## Quick start`, `## Usage` and `## Project` into that order, naming for each section the README's own text it takes, so no line of the project's is lost (the template's ADR-0055 and ADR-0061). When a gap is the blank `repository` answer, the update step's `-Data` gets `repository = ''`, the project's GitHub repository. Its Done-when runs `$o = @(./.template/Test-Readme.ps1); if (-not $? -or $LASTEXITCODE -or ($o -match '^(Warning: |::warning::)')) { exit 1 } else { exit 0 }`, which also fails on a gap the check only warns about, under GitHub Actions too. - 5. When the project has `changelog.d/README.md` after the trial's update and `./.template/Publish-Release.ps1 -Fold -WhatIf`, run in the trial's clone, doesn't print `Nothing to fold.`, one step titled `Fold published changelog entries into `, before the gate. Its Change runs `./.template/Publish-Release.ps1 -Fold`, which writes each published release whose entries are still in `changelog.d/` into the changelog as its section and deletes those files (ADR-0081 in `docs/decisions/project-template/`); its Files line names the changelog and the entry files the trial's run named; its Done-when is `$o = @(./.template/Publish-Release.ps1 -Fold -WhatIf); if ($? -and ($o -join ' ') -match 'Nothing to fold\.') { exit 0 } else { exit 1 }`. + 5. When the project has `changelog.d/README.md` after the trial's update and `./.template/Publish-Release.ps1 -Fold -WhatIf`, run in the trial's clone, doesn't print `Nothing to fold.`, one step titled `Fold changelog entries into `, before the gate. Its Change runs `./.template/Publish-Release.ps1 -Fold`, which writes each published release whose entries are still in `changelog.d/` into the changelog as its section, and, under `release: none` in `AGENTS.md`'s Landing section, each entry file no release published into its `## [Unreleased]`, and deletes those files (ADR-0081 and ADR-0087 in `docs/decisions/project-template/`); its Files line names the changelog and the entry files the trial's run named; its Done-when is `$o = @(./.template/Publish-Release.ps1 -Fold -WhatIf); if ($? -and ($o -join ' ') -match 'Nothing to fold\.') { exit 0 } else { exit 1 }`. 6. The gate, last: the gate `AGENTS.md` names, or else `build_command` and then `test_command`. When the trial adds `.github/workflows/codeql.yml`, its output says so, with the commands written for this project's own GitHub repository, which the trial's clone has as its `origin`. The plan's Review checklist then starts with a step for the person, done before the update's pull request can pass, since GitHub refuses the workflow's results while CodeQL's default setup is on and an executor never calls `gh`: list the default setup's languages with `gh api repos///code-scanning/default-setup --jq .languages`, turn the default setup off with `gh api -X PATCH repos///code-scanning/default-setup -f state=not-configured`, and re-run the pull request's failed Analyze jobs. No step of the plan runs either command. diff --git a/.copier-answers.yml b/.copier-answers.yml index c291a2c..5458564 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,5 +1,5 @@ # Written by Copier; never edit by hand. Change an answer with .template\Update-Project.ps1 -Data. -_commit: v0.165.0 +_commit: v0.166.0 _src_path: https://github.com/NCodeGroup/project-template.git author_name: NCode Group best_practices_project: '17129' diff --git a/.github/instructions/project-template.instructions.md b/.github/instructions/project-template.instructions.md index 627360b..8e121de 100644 --- a/.github/instructions/project-template.instructions.md +++ b/.github/instructions/project-template.instructions.md @@ -23,7 +23,7 @@ Work in this repository is planned by a frontier model and executed by cheaper o - A finished step is committed as `Plan step N: `, staging only the files the step lists (never `git add -A`, never `PLAN.md`); a re-planned step is recorded as an empty commit, `Re-plan step N: <title>`. - The workflow commands are in Claude Code (`.claude/commands/`), VS Code's Copilot Chat (`.github/prompts/` and `.github/agents/`) and Copilot CLI (`.github/skills/`), and `PLAN.md` is the only state they share: any of them can plan, execute, re-plan or review the same plan, whichever wrote the steps before. - `/ship-plan` lands a reviewed plan as the `## Landing` section of `AGENTS.md` says. `integrate: pull-request`, the default, pushes the plan's branch and opens a pull request whose description summarizes the plan and ends with one `Closes <issue reference>` line per issue, then one per open follow-up issue the plan's work completes, which it records on a `Completes:` line of `PLAN.md`, then one `Refs <issue reference>` line per issue it only refers to. Before it opens the pull request, and each time it pushes to an open one, it lists the open issues labelled `follow-up`, or the label `follow-up-label` names, created since the plan's branch left the default branch, or every open one when the branch changes `.copier-answers.yml`'s `_commit:` line, as a template update does, and judges each against the branch's diff from the default branch, as a review would, never by its title alone; an issue the work only partly completes stays open and, once the plan has landed, gets an `Autopilot:` comment naming what the plan did and what remains, and its body rewritten to describe only what remains. `integrate: direct` pushes its commits to the default branch, after it looks for the same follow-up issues, and once the commits land it comments on and closes each one its work completes, because no pull request closes them; when the default branch has moved since the plan branched, it first adds a step that merges it in, because that push must fast-forward, and lands once that step is reviewed. `release: tag` or `tag+release` also tags the plan's `Release:` version and publishes a release from that version's section of the `changelog` file (default `CHANGELOG.md`); the default, `release: none`, does neither. A plan has a `Release:` line only when it changes something a release ships: the product's code, a file its package carries, such as the readme nuget.org shows, or its build output. A plan that changes only documentation-site pages, which deploy from every push, CI, decision records, tests or repository docs has none: `/ship-plan` lands it with no tag and no release, and its changelog entries wait under `## [Unreleased]` for the next release, as ADR-0032 in `docs/decisions/project-template/` says. It writes that version into the pull request's description as a `Release: <version>` line. On GitHub, `.github/workflows/tag-release.yml` reads it, or the changelog's newest section, and tags and publishes the release as the pull request merges, so `/ship-plan` run after the merge finds both done and does them only when that workflow didn't. When another plan has landed the `Release:` version first, it adds a step that merges in the default branch and moves the plan's changelog section to the next free version, which `.template/Get-PlanState.ps1` prints as `renumber`, and lands once that step is reviewed. In a pre-release project, whose changelog has no release section, it moves only the plan's `Release:` line and adds no step. While the plan's pull request is open, the next `/ship-plan` after that review pushes the step to it. When the default branch changed files the plan also changed, so its pull request would conflict, it doesn't push or open it: it adds a step that merges in the default branch and resolves the files the state script's `conflicts` line names, and lands once that step is reviewed. It never merges the default branch in when the merge is clean. `draft: yes` opens the pull request as a draft, as `/ship-plan draft` does; the default is `draft: no`. `gate: <command>` runs that command from the repository root before it pushes, such as `gate: ./build/dod.ps1 -Fast`, and stops when it exits non-zero or changes a file; the default, `gate: none`, runs nothing. `prelude: <command>` names one PowerShell command that sets up the shell, such as `prelude: ./build/env.ps1`, a script in the repository that puts a tool installed through a version manager on `PATH`: `/ship-plan`, `/run-issues`, `/address-feedback` and `/run-feedback` dot-source it before the gate, executors and coordinators before each Done-when command, in the same PowerShell, and plans name it in Context for the executor instead of repeating a guard in every step. When it fails, they stop and show its error; the default, `prelude: none`, runs nothing. `pr-format: <file>#<heading>` writes the pull request's title and description as that section of the file says, such as a conventional-commit title; the default, `pr-format: none`, uses the plan's title and a short summary. Without a Landing section, or for a key it leaves out, the defaults apply. It asks once before it pushes, drops the empty `Plan:` and `Re-plan step` commits from a branch that was never pushed, comments on and closes each of the plan's issues, and files its follow-ups as issues labelled `follow-up`, or the label `follow-up-label` names, except the ones you drop: in this repository with `follow-ups: issues`, the default, in another with `follow-ups: <owner/repo>`, or nowhere with `follow-ups: none`, where it lists them for you to record. With `follow-ups: issues`, you can also name follow-ups to act on next: they are filed too, and `/finish-plan` then names `/plan-issue #<number>` for each. Before the plan lands, you can instead name follow-ups to fix in its pull request: each becomes a step of the plan, and nothing is filed for it. Run it again after a pull request merges, or after it stopped, and it carries on where it left off. -- The changelog, the file the `changelog` key of the `## Landing` section names (default `CHANGELOG.md`), follows [Keep a Changelog 1.1.0](https://keepachangelog.com/en/1.1.0/). It has `## [Unreleased]` first, then one `## [1.4.0] - 2026-10-28` section per release, newest first, with entries grouped under `### Added`, `### Changed`, `### Deprecated`, `### Removed`, `### Fixed` and `### Security`, and compare links at the end. Every plan's last step writes it. A plan without a `Release:` line adds its entries under `## [Unreleased]`, and a plan with one moves them into its new version's section. The first such step creates the file when the project has none. Where the project has `changelog.d/README.md`, a plan writes its entries to a file of its own, `changelog.d/<date>-<branch>.md`, instead, and never edits the changelog: the release its merge makes takes the version its `Release:` line names, or the next free one, and its notes from the entry files the merge added, and `.template/Publish-Release.ps1 -Fold`, run in a pull request of its own, writes published entries into the changelog (ADR-0081). A changelog in another format, such as one an adopted project already had, is left as it is: plans with a `Release:` line add sections in its own style, and plans without one don't touch it. To change that, have a plan convert it, such as `/plan-migration Convert CHANGELOG.md to Keep a Changelog 1.1.0`. When the project has version tags the changelog has no section for, such as releases from before it had one, `Update-Project.ps1` and the template's `Adopt-Project.ps1` print a `/plan-migration` request to backfill them, and each plan lists the backfill as a follow-up until it lands. In a pre-release project, the changelog describes the product as it is instead: `## [Unreleased]` holds only `### Added` and `### Security`, every plan's last step edits its entries in place to match the code, the file has no release section, a release's notes are that section, and the version tags before 1.0.0 need none; the plan that releases the first stable version moves the entries into that version's section. +- The changelog, the file the `changelog` key of the `## Landing` section names (default `CHANGELOG.md`), follows [Keep a Changelog 1.1.0](https://keepachangelog.com/en/1.1.0/). It has `## [Unreleased]` first, then one `## [1.4.0] - 2026-10-28` section per release, newest first, with entries grouped under `### Added`, `### Changed`, `### Deprecated`, `### Removed`, `### Fixed` and `### Security`, and compare links at the end. Every plan's last step writes it. A plan without a `Release:` line adds its entries under `## [Unreleased]`, and a plan with one moves them into its new version's section. The first such step creates the file when the project has none. Where the project has `changelog.d/README.md`, a plan writes its entries to a file of its own, `changelog.d/<date>-<branch>.md`, instead, and never edits the changelog: the release its merge makes takes the version its `Release:` line names, or the next free one, and its notes from the entry files the merge added, and `.template/Publish-Release.ps1 -Fold`, run in a pull request of its own, writes published entries into the changelog (ADR-0081). A workflow or script of the project's own that publishes a release reads its notes with `.template/Publish-Release.ps1 -Notes <version> -OutFile <file>`; under `release: none`, `-Fold` also writes the entry files no release published into `## [Unreleased]`, and a release made by hand is tagged first, then folded in a pull request of its own (ADR-0087). A changelog in another format, such as one an adopted project already had, is left as it is: plans with a `Release:` line add sections in its own style, and plans without one don't touch it. To change that, have a plan convert it, such as `/plan-migration Convert CHANGELOG.md to Keep a Changelog 1.1.0`. When the project has version tags the changelog has no section for, such as releases from before it had one, `Update-Project.ps1` and the template's `Adopt-Project.ps1` print a `/plan-migration` request to backfill them, and each plan lists the backfill as a follow-up until it lands. In a pre-release project, the changelog describes the product as it is instead: `## [Unreleased]` holds only `### Added` and `### Security`, every plan's last step edits its entries in place to match the code, the file has no release section, a release's notes are that section, and the version tags before 1.0.0 need none; the plan that releases the first stable version moves the entries into that version's section. - A clean `/review-plan-diff` records the commit it reviewed on a `Reviewed:` line in `PLAN.md`, and `/ship-plan` lands only work that matches it. `/continue-plan` shows where each open plan stands and the command to run next. Both run `.template/Get-PlanState.ps1`, which prints those facts for the plan in a folder. - Never push, force-push or open a pull request unless asked. Don't count on an approval prompt to stop a push: `git push` can run without one, as `.claude/settings.json` lets it in Claude Code, so the check that follows is what catches an unexpected push. Before a push you were asked for, list what the unpushed commits contain and stop on anything unexpected, such as `PLAN.md`, secrets or large files. Run `git fetch origin`, then `git log --stat origin/<branch>..` when `origin` has the branch you push to, or `git log --stat origin/<default branch>..` when it doesn't yet, as before a plan branch's first push; `git ls-remote --exit-code --heads origin <branch>` exits 0 when it has the branch and 2 when it doesn't; stop and report on any other exit, because that means `origin` couldn't say. Compare with `origin`, not the branch's upstream: a plan branch made with `--no-track` has none, and one made from the default branch tracks that branch instead of its own. - Before such a push, made without `/ship-plan`, retire a finished plan: when every step in `PLAN.md` is marked `[x]`, the review's fix steps included, delete `PLAN.md`, so no finished plan is left in the checkout. When a step is still open, keep `PLAN.md` and say which steps remain before you push. Unless the Landing section says `follow-ups: none`, first find the follow-up issues the branch completes, as `/ship-plan` does: the open issues labelled `follow-up`, or the label `follow-up-label` names, created since the branch left the default branch, or every open one when the branch changes `.copier-answers.yml`'s `_commit:` line, as a template update does, each judged against `git diff origin/<default branch>...HEAD` as a review would, never by its title alone; put each one the work completes on the plan's `Completes:` line. When it has an `Issue:` or `Completes:` line, draft the pull request description from it before deleting it: as the section the Landing section's `pr-format` names says, or two to five lines summarizing its steps and Decisions, then one `Closes <issue reference>` line per issue on the `Issue:` line, then one per issue on its `Completes:` line, then one `Refs <issue reference>` line per issue on its `Refs:` line, each on a line of its own, such as `Closes #42` and `Refs owner/repo#90`. Use it when you open the pull request, or put it in the open one with `gh pr edit <number> --body-file <file>`; when you weren't asked for a pull request, give it in your reply. When the push goes straight to the default branch, as with `integrate: direct`, no pull request closes those issues: note the issues on the `Issue:` and `Completes:` lines before you delete `PLAN.md`, and once the commits land, comment on each one still open that the work completes it, naming the commit, then close it. `/ship-plan` keeps `PLAN.md` until `/finish-plan` deletes it. diff --git a/.github/prompts/plan-issue.prompt.md b/.github/prompts/plan-issue.prompt.md index 5cb9145..dbed07f 100644 --- a/.github/prompts/plan-issue.prompt.md +++ b/.github/prompts/plan-issue.prompt.md @@ -211,7 +211,7 @@ Clone into a scratch folder outside the repository, `$scratch = Join-Path ([IO.P 2. A check step: `build_command` and the checks the trial ran in the clone, now in the repository. 3. One step for each project file that step 3 found, with its exact old and new text. 4. When the trial printed `README.md doesn't follow the .NET library layout yet`, one step titled `Bring README.md to the .NET library layout`, after the project-file steps. Its Change runs `./.template/Test-Readme.ps1 -Fix`, which puts the template's header block at the top of a README that has none, the `## Project` block right below a `## Project` heading that has none and the package header block at the top of each package readme that has none, then deletes the old title, description and badge lines the header block replaces, quoting each, keeps the library's own badges, such as a coverage badge, in a centred `<p align="center">` paragraph right below the header block, deletes the `## Project` links the block repeats, keeping the project's own below it, deletes each package readme's old title and the badges its block repeats, keeping the package's own badges on a line right below the block, writes a package readme the trial names as missing, with what the package is for, `## Installation` and an example, and adds or moves `## Installation`, `## Quick start`, `## Usage` and `## Project` into that order, naming for each section the README's own text it takes, so no line of the project's is lost (the template's ADR-0055 and ADR-0061). When a gap is the blank `repository` answer, the update step's `-Data` gets `repository = '<Owner/Name>'`, the project's GitHub repository. Its Done-when runs `$o = @(./.template/Test-Readme.ps1); if (-not $? -or $LASTEXITCODE -or ($o -match '^(Warning: |::warning::)')) { exit 1 } else { exit 0 }`, which also fails on a gap the check only warns about, under GitHub Actions too. - 5. When the project has `changelog.d/README.md` after the trial's update and `./.template/Publish-Release.ps1 -Fold -WhatIf`, run in the trial's clone, doesn't print `Nothing to fold.`, one step titled `Fold published changelog entries into <changelog>`, before the gate. Its Change runs `./.template/Publish-Release.ps1 -Fold`, which writes each published release whose entries are still in `changelog.d/` into the changelog as its section and deletes those files (ADR-0081 in `docs/decisions/project-template/`); its Files line names the changelog and the entry files the trial's run named; its Done-when is `$o = @(./.template/Publish-Release.ps1 -Fold -WhatIf); if ($? -and ($o -join ' ') -match 'Nothing to fold\.') { exit 0 } else { exit 1 }`. + 5. When the project has `changelog.d/README.md` after the trial's update and `./.template/Publish-Release.ps1 -Fold -WhatIf`, run in the trial's clone, doesn't print `Nothing to fold.`, one step titled `Fold changelog entries into <changelog>`, before the gate. Its Change runs `./.template/Publish-Release.ps1 -Fold`, which writes each published release whose entries are still in `changelog.d/` into the changelog as its section, and, under `release: none` in `AGENTS.md`'s Landing section, each entry file no release published into its `## [Unreleased]`, and deletes those files (ADR-0081 and ADR-0087 in `docs/decisions/project-template/`); its Files line names the changelog and the entry files the trial's run named; its Done-when is `$o = @(./.template/Publish-Release.ps1 -Fold -WhatIf); if ($? -and ($o -join ' ') -match 'Nothing to fold\.') { exit 0 } else { exit 1 }`. 6. The gate, last: the gate `AGENTS.md` names, or else `build_command` and then `test_command`. When the trial adds `.github/workflows/codeql.yml`, its output says so, with the commands written for this project's own GitHub repository, which the trial's clone has as its `origin`. The plan's Review checklist then starts with a step for the person, done before the update's pull request can pass, since GitHub refuses the workflow's results while CodeQL's default setup is on and an executor never calls `gh`: list the default setup's languages with `gh api repos/<owner>/<name>/code-scanning/default-setup --jq .languages`, turn the default setup off with `gh api -X PATCH repos/<owner>/<name>/code-scanning/default-setup -f state=not-configured`, and re-run the pull request's failed Analyze jobs. No step of the plan runs either command. diff --git a/.github/prompts/plan-template-update.prompt.md b/.github/prompts/plan-template-update.prompt.md index 232a526..75144dc 100644 --- a/.github/prompts/plan-template-update.prompt.md +++ b/.github/prompts/plan-template-update.prompt.md @@ -47,7 +47,7 @@ Clone into a scratch folder outside the repository, `$scratch = Join-Path ([IO.P 2. A check step: `build_command` and the checks the trial ran in the clone, now in the repository. 3. One step for each project file that step 3 found, with its exact old and new text. 4. When the trial printed `README.md doesn't follow the .NET library layout yet`, one step titled `Bring README.md to the .NET library layout`, after the project-file steps. Its Change runs `./.template/Test-Readme.ps1 -Fix`, which puts the template's header block at the top of a README that has none, the `## Project` block right below a `## Project` heading that has none and the package header block at the top of each package readme that has none, then deletes the old title, description and badge lines the header block replaces, quoting each, keeps the library's own badges, such as a coverage badge, in a centred `<p align="center">` paragraph right below the header block, deletes the `## Project` links the block repeats, keeping the project's own below it, deletes each package readme's old title and the badges its block repeats, keeping the package's own badges on a line right below the block, writes a package readme the trial names as missing, with what the package is for, `## Installation` and an example, and adds or moves `## Installation`, `## Quick start`, `## Usage` and `## Project` into that order, naming for each section the README's own text it takes, so no line of the project's is lost (the template's ADR-0055 and ADR-0061). When a gap is the blank `repository` answer, the update step's `-Data` gets `repository = '<Owner/Name>'`, the project's GitHub repository. Its Done-when runs `$o = @(./.template/Test-Readme.ps1); if (-not $? -or $LASTEXITCODE -or ($o -match '^(Warning: |::warning::)')) { exit 1 } else { exit 0 }`, which also fails on a gap the check only warns about, under GitHub Actions too. - 5. When the project has `changelog.d/README.md` after the trial's update and `./.template/Publish-Release.ps1 -Fold -WhatIf`, run in the trial's clone, doesn't print `Nothing to fold.`, one step titled `Fold published changelog entries into <changelog>`, before the gate. Its Change runs `./.template/Publish-Release.ps1 -Fold`, which writes each published release whose entries are still in `changelog.d/` into the changelog as its section and deletes those files (ADR-0081 in `docs/decisions/project-template/`); its Files line names the changelog and the entry files the trial's run named; its Done-when is `$o = @(./.template/Publish-Release.ps1 -Fold -WhatIf); if ($? -and ($o -join ' ') -match 'Nothing to fold\.') { exit 0 } else { exit 1 }`. + 5. When the project has `changelog.d/README.md` after the trial's update and `./.template/Publish-Release.ps1 -Fold -WhatIf`, run in the trial's clone, doesn't print `Nothing to fold.`, one step titled `Fold changelog entries into <changelog>`, before the gate. Its Change runs `./.template/Publish-Release.ps1 -Fold`, which writes each published release whose entries are still in `changelog.d/` into the changelog as its section, and, under `release: none` in `AGENTS.md`'s Landing section, each entry file no release published into its `## [Unreleased]`, and deletes those files (ADR-0081 and ADR-0087 in `docs/decisions/project-template/`); its Files line names the changelog and the entry files the trial's run named; its Done-when is `$o = @(./.template/Publish-Release.ps1 -Fold -WhatIf); if ($? -and ($o -join ' ') -match 'Nothing to fold\.') { exit 0 } else { exit 1 }`. 6. The gate, last: the gate `AGENTS.md` names, or else `build_command` and then `test_command`. When the trial adds `.github/workflows/codeql.yml`, its output says so, with the commands written for this project's own GitHub repository, which the trial's clone has as its `origin`. The plan's Review checklist then starts with a step for the person, done before the update's pull request can pass, since GitHub refuses the workflow's results while CodeQL's default setup is on and an executor never calls `gh`: list the default setup's languages with `gh api repos/<owner>/<name>/code-scanning/default-setup --jq .languages`, turn the default setup off with `gh api -X PATCH repos/<owner>/<name>/code-scanning/default-setup -f state=not-configured`, and re-run the pull request's failed Analyze jobs. No step of the plan runs either command. diff --git a/.github/skills/plan-issue/SKILL.md b/.github/skills/plan-issue/SKILL.md index 6f56dc8..bb61396 100644 --- a/.github/skills/plan-issue/SKILL.md +++ b/.github/skills/plan-issue/SKILL.md @@ -209,7 +209,7 @@ Clone into a scratch folder outside the repository, `$scratch = Join-Path ([IO.P 2. A check step: `build_command` and the checks the trial ran in the clone, now in the repository. 3. One step for each project file that step 3 found, with its exact old and new text. 4. When the trial printed `README.md doesn't follow the .NET library layout yet`, one step titled `Bring README.md to the .NET library layout`, after the project-file steps. Its Change runs `./.template/Test-Readme.ps1 -Fix`, which puts the template's header block at the top of a README that has none, the `## Project` block right below a `## Project` heading that has none and the package header block at the top of each package readme that has none, then deletes the old title, description and badge lines the header block replaces, quoting each, keeps the library's own badges, such as a coverage badge, in a centred `<p align="center">` paragraph right below the header block, deletes the `## Project` links the block repeats, keeping the project's own below it, deletes each package readme's old title and the badges its block repeats, keeping the package's own badges on a line right below the block, writes a package readme the trial names as missing, with what the package is for, `## Installation` and an example, and adds or moves `## Installation`, `## Quick start`, `## Usage` and `## Project` into that order, naming for each section the README's own text it takes, so no line of the project's is lost (the template's ADR-0055 and ADR-0061). When a gap is the blank `repository` answer, the update step's `-Data` gets `repository = '<Owner/Name>'`, the project's GitHub repository. Its Done-when runs `$o = @(./.template/Test-Readme.ps1); if (-not $? -or $LASTEXITCODE -or ($o -match '^(Warning: |::warning::)')) { exit 1 } else { exit 0 }`, which also fails on a gap the check only warns about, under GitHub Actions too. - 5. When the project has `changelog.d/README.md` after the trial's update and `./.template/Publish-Release.ps1 -Fold -WhatIf`, run in the trial's clone, doesn't print `Nothing to fold.`, one step titled `Fold published changelog entries into <changelog>`, before the gate. Its Change runs `./.template/Publish-Release.ps1 -Fold`, which writes each published release whose entries are still in `changelog.d/` into the changelog as its section and deletes those files (ADR-0081 in `docs/decisions/project-template/`); its Files line names the changelog and the entry files the trial's run named; its Done-when is `$o = @(./.template/Publish-Release.ps1 -Fold -WhatIf); if ($? -and ($o -join ' ') -match 'Nothing to fold\.') { exit 0 } else { exit 1 }`. + 5. When the project has `changelog.d/README.md` after the trial's update and `./.template/Publish-Release.ps1 -Fold -WhatIf`, run in the trial's clone, doesn't print `Nothing to fold.`, one step titled `Fold changelog entries into <changelog>`, before the gate. Its Change runs `./.template/Publish-Release.ps1 -Fold`, which writes each published release whose entries are still in `changelog.d/` into the changelog as its section, and, under `release: none` in `AGENTS.md`'s Landing section, each entry file no release published into its `## [Unreleased]`, and deletes those files (ADR-0081 and ADR-0087 in `docs/decisions/project-template/`); its Files line names the changelog and the entry files the trial's run named; its Done-when is `$o = @(./.template/Publish-Release.ps1 -Fold -WhatIf); if ($? -and ($o -join ' ') -match 'Nothing to fold\.') { exit 0 } else { exit 1 }`. 6. The gate, last: the gate `AGENTS.md` names, or else `build_command` and then `test_command`. When the trial adds `.github/workflows/codeql.yml`, its output says so, with the commands written for this project's own GitHub repository, which the trial's clone has as its `origin`. The plan's Review checklist then starts with a step for the person, done before the update's pull request can pass, since GitHub refuses the workflow's results while CodeQL's default setup is on and an executor never calls `gh`: list the default setup's languages with `gh api repos/<owner>/<name>/code-scanning/default-setup --jq .languages`, turn the default setup off with `gh api -X PATCH repos/<owner>/<name>/code-scanning/default-setup -f state=not-configured`, and re-run the pull request's failed Analyze jobs. No step of the plan runs either command. diff --git a/.github/skills/plan-template-update/SKILL.md b/.github/skills/plan-template-update/SKILL.md index 063becf..4e2b3de 100644 --- a/.github/skills/plan-template-update/SKILL.md +++ b/.github/skills/plan-template-update/SKILL.md @@ -45,7 +45,7 @@ Clone into a scratch folder outside the repository, `$scratch = Join-Path ([IO.P 2. A check step: `build_command` and the checks the trial ran in the clone, now in the repository. 3. One step for each project file that step 3 found, with its exact old and new text. 4. When the trial printed `README.md doesn't follow the .NET library layout yet`, one step titled `Bring README.md to the .NET library layout`, after the project-file steps. Its Change runs `./.template/Test-Readme.ps1 -Fix`, which puts the template's header block at the top of a README that has none, the `## Project` block right below a `## Project` heading that has none and the package header block at the top of each package readme that has none, then deletes the old title, description and badge lines the header block replaces, quoting each, keeps the library's own badges, such as a coverage badge, in a centred `<p align="center">` paragraph right below the header block, deletes the `## Project` links the block repeats, keeping the project's own below it, deletes each package readme's old title and the badges its block repeats, keeping the package's own badges on a line right below the block, writes a package readme the trial names as missing, with what the package is for, `## Installation` and an example, and adds or moves `## Installation`, `## Quick start`, `## Usage` and `## Project` into that order, naming for each section the README's own text it takes, so no line of the project's is lost (the template's ADR-0055 and ADR-0061). When a gap is the blank `repository` answer, the update step's `-Data` gets `repository = '<Owner/Name>'`, the project's GitHub repository. Its Done-when runs `$o = @(./.template/Test-Readme.ps1); if (-not $? -or $LASTEXITCODE -or ($o -match '^(Warning: |::warning::)')) { exit 1 } else { exit 0 }`, which also fails on a gap the check only warns about, under GitHub Actions too. - 5. When the project has `changelog.d/README.md` after the trial's update and `./.template/Publish-Release.ps1 -Fold -WhatIf`, run in the trial's clone, doesn't print `Nothing to fold.`, one step titled `Fold published changelog entries into <changelog>`, before the gate. Its Change runs `./.template/Publish-Release.ps1 -Fold`, which writes each published release whose entries are still in `changelog.d/` into the changelog as its section and deletes those files (ADR-0081 in `docs/decisions/project-template/`); its Files line names the changelog and the entry files the trial's run named; its Done-when is `$o = @(./.template/Publish-Release.ps1 -Fold -WhatIf); if ($? -and ($o -join ' ') -match 'Nothing to fold\.') { exit 0 } else { exit 1 }`. + 5. When the project has `changelog.d/README.md` after the trial's update and `./.template/Publish-Release.ps1 -Fold -WhatIf`, run in the trial's clone, doesn't print `Nothing to fold.`, one step titled `Fold changelog entries into <changelog>`, before the gate. Its Change runs `./.template/Publish-Release.ps1 -Fold`, which writes each published release whose entries are still in `changelog.d/` into the changelog as its section, and, under `release: none` in `AGENTS.md`'s Landing section, each entry file no release published into its `## [Unreleased]`, and deletes those files (ADR-0081 and ADR-0087 in `docs/decisions/project-template/`); its Files line names the changelog and the entry files the trial's run named; its Done-when is `$o = @(./.template/Publish-Release.ps1 -Fold -WhatIf); if ($? -and ($o -join ' ') -match 'Nothing to fold\.') { exit 0 } else { exit 1 }`. 6. The gate, last: the gate `AGENTS.md` names, or else `build_command` and then `test_command`. When the trial adds `.github/workflows/codeql.yml`, its output says so, with the commands written for this project's own GitHub repository, which the trial's clone has as its `origin`. The plan's Review checklist then starts with a step for the person, done before the update's pull request can pass, since GitHub refuses the workflow's results while CodeQL's default setup is on and an executor never calls `gh`: list the default setup's languages with `gh api repos/<owner>/<name>/code-scanning/default-setup --jq .languages`, turn the default setup off with `gh api -X PATCH repos/<owner>/<name>/code-scanning/default-setup -f state=not-configured`, and re-run the pull request's failed Analyze jobs. No step of the plan runs either command. diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 4b7c7d2..33d2d01 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -37,9 +37,11 @@ jobs: permissions: contents: read steps: - # The same step is in codeql.yml's languages job, scorecard.yml's visibility job and tag-release.yml's policy - # job; keep the four the same (the template's tests/Test-Template.ps1 checks it). The template owns this file, so - # the copies a project adds in workflows of its own are listed in codeql.yml's comment, which the project owns. + # The same step is in the template's codeql.yml, in its languages job, and in scorecard.yml's visibility job and + # tag-release.yml's policy job; keep the four the same (the template's tests/Test-Template.ps1 checks it). The + # template owns this file, so a project lists the copies it adds in workflows of its own in its CodeQL workflow, + # which it owns: in the comment above the step in codeql.yml, or, in a CodeQL workflow of its own without the + # step (the template's ADR-0047), on a header comment line that starts "The project's own copies:". - name: Read whether the repository is public id: visibility shell: pwsh diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index b3f83da..5df0af6 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -30,9 +30,11 @@ jobs: outputs: public: ${{ steps.visibility.outputs.public }} steps: - # The same step is in codeql.yml's languages job, dependency-review.yml and tag-release.yml's policy job; - # keep the four the same (the template's tests/Test-Template.ps1 checks it). The template owns this file, so the - # copies a project adds in workflows of its own are listed in codeql.yml's comment, which the project owns. + # The same step is in the template's codeql.yml, in its languages job, and in dependency-review.yml and + # tag-release.yml's policy job; keep the four the same (the template's tests/Test-Template.ps1 checks it). The + # template owns this file, so a project lists the copies it adds in workflows of its own in its CodeQL workflow, + # which it owns: in the comment above the step in codeql.yml, or, in a CodeQL workflow of its own without the + # step (the template's ADR-0047), on a header comment line that starts "The project's own copies:". - name: Read whether the repository is public id: visibility shell: pwsh diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml index 77485a6..86a30fd 100644 --- a/.github/workflows/tag-release.yml +++ b/.github/workflows/tag-release.yml @@ -86,9 +86,11 @@ jobs: # A public repository's tag is signed, so the release job needs the visibility. It is read from the REST API # because a scheduled run's event payload may carry no repository (the template's ADR-0056). - # The same step is in codeql.yml's languages job, scorecard.yml's visibility job and dependency-review.yml; keep - # the four the same (the template's tests/Test-Template.ps1 checks it). The template owns this file, so the - # copies a project adds in workflows of its own are listed in codeql.yml's comment, which the project owns. + # The same step is in the template's codeql.yml, in its languages job, and in scorecard.yml's visibility job and + # dependency-review.yml; keep the four the same (the template's tests/Test-Template.ps1 checks it). The template + # owns this file, so a project lists the copies it adds in workflows of its own in its CodeQL workflow, which it + # owns: in the comment above the step in codeql.yml, or, in a CodeQL workflow of its own without the step (the + # template's ADR-0047), on a header comment line that starts "The project's own copies:". - name: Read whether the repository is public id: visibility if: steps.policy.outputs.release == 'tag' || steps.policy.outputs.release == 'tag+release' diff --git a/.template-version b/.template-version index 7ce2352..961e260 100644 --- a/.template-version +++ b/.template-version @@ -1 +1 @@ -v0.165.0 +v0.166.0 diff --git a/.template/Publish-Release.ps1 b/.template/Publish-Release.ps1 index f24ac99..cfedddc 100644 --- a/.template/Publish-Release.ps1 +++ b/.template/Publish-Release.ps1 @@ -70,7 +70,8 @@ .github/workflows/publish-chart.yml instead, the same way; with both, publish-image.yml starts publish-chart.yml itself once every image is recorded (the template's ADR-0076). - With -Fold it moves the entry files that releases published into the changelog instead (see -Fold). + With -Fold it moves the entry files that releases published into the changelog instead (see -Fold), and with -Notes + it writes a version's notes to a file (see -Notes). .PARAMETER Commit The commit to tag: in the workflow, the commit the push made main point to. @@ -118,6 +119,26 @@ above the first older section, with its link line. The entry files it took in and the `## [Unreleased]` lines it took in are deleted. It writes the working tree and commits nothing, so a person runs it in a pull request of its own. -WhatIf prints the releases and files and changes nothing. It prints `Nothing to fold.` when there is none. + Under release: none, where no merge releases anything, it also folds each entry file no release published, one HEAD + has and the commit of the newest version tag merged into HEAD lacks (a tag below 1.0.0 doesn't count in a + pre-release: untracked project), into ## [Unreleased], merged with the entries there under one heading per group, + in the order the files reached the branch, and deletes it (the template's ADR-0087). + Without AGENTS.md it runs as under release: none. + +.PARAMETER Notes + Write the notes of this version, v1.2.3 or 1.2.3, to -OutFile, and exit without tagging or publishing, under any + release policy (the template's ADR-0087). It reads at the commit of the version's tag when the clone has it, else at + -Commit. The notes are the version's changelog section with the entry files that the previous version tag's commit + lacks and the lines `## [Unreleased]` gained since that tag; without a section they are those alone; in a + pre-release: untracked project whose changelog has no release section they are all of `## [Unreleased]` and every + entry file. Without changelog.d/README.md they are the section, or such a pre-release project's `## [Unreleased]`. + It counts the clone's own tags, which a checkout with fetch-depth: 0 holds, and it fails when the notes are empty. + A project's own publishing workflow, or a person releasing by hand, reads a release's notes this way rather than + from the changelog alone, which lacks the entries still in changelog.d/. + Without AGENTS.md it runs as under release: none. + +.PARAMETER OutFile + The file -Notes writes, UTF-8 without a byte order mark. .EXAMPLE ./.template/Publish-Release.ps1 -Commit $env:GITHUB_SHA @@ -136,6 +157,9 @@ .EXAMPLE ./.template/Publish-Release.ps1 -Fold + +.EXAMPLE + ./.template/Publish-Release.ps1 -Notes v1.2.3 -OutFile release-notes.md #> [CmdletBinding(SupportsShouldProcess)] param( @@ -146,7 +170,9 @@ param( [switch]$Sign, [switch]$Find, [switch]$RequireCommit, - [switch]$Fold + [switch]$Fold, + [string]$Notes, + [string]$OutFile ) $ErrorActionPreference = 'Stop' Set-StrictMode -Version Latest @@ -178,11 +204,11 @@ function Get-LandingPolicy([string[]]$Lines) { $landing } -# The changelog's newest release section: its number, its heading's text and its notes, without the heading and the -# blank lines around them. -function Get-NewestRelease([string[]]$Lines) { +# The changelog's newest release section, or, with -Number, the section of that version: its number, its heading's text +# and its notes, without the heading and the blank lines around them. +function Get-NewestRelease([string[]]$Lines, [string]$Number = '') { for ($i = 0; $i -lt $Lines.Count; $i++) { - if ($Lines[$i] -notmatch '^## \[(?<number>[^\]]+)\]' -or $Matches.number -eq 'Unreleased') { continue } + if ($Lines[$i] -notmatch '^## \[(?<number>[^\]]+)\]' -or $Matches.number -eq 'Unreleased' -or ($Number -and ($Matches.number -replace '^v') -ne $Number)) { continue } $number = $Matches.number $notes = [Collections.Generic.List[string]]::new() for ($j = $i + 1; $j -lt $Lines.Count -and $Lines[$j] -notmatch '^## ' -and $Lines[$j] -notmatch '^\[[^\]]+\]:\s'; $j++) { @@ -207,6 +233,12 @@ function Get-UnreleasedNotes([string[]]$Lines) { '' } +# The index of the changelog's ## [Unreleased] line in $Lines, or -1. +function Find-UnreleasedHeading($Lines) { + for ($i = 0; $i -lt $Lines.Count; $i++) { if ($Lines[$i] -match '^## \[Unreleased\]') { return $i } } + -1 +} + # GitHub's anchor for a Markdown heading's text. function Get-HeadingAnchor([string]$Text) { ($Text.Trim().ToLowerInvariant() -replace '[^\p{L}\p{M}\p{N}\p{Pc} -]', '') -replace ' ', '-' @@ -407,6 +439,38 @@ function Get-EntryNotes([string]$Sha, [string]$Previous, [switch]$All) { } } +# Writes the notes of the release $Version to $Path, as -Notes describes (the template's ADR-0087). +function Write-VersionNote([string]$Version, [string]$Path) { + if ($Version -cnotmatch '^v?(?<number>[0-9]+\.[0-9]+\.[0-9]+)\z') { throw "-Notes takes a release version such as v1.2.3 or 1.2.3, not '$Version'." } + $number = $Matches.number + $tags = @(& git tag --list) + if ($LASTEXITCODE) { throw "Can't list the tags of this clone (git tag exited $LASTEXITCODE)." } + $versionTags = @($tags | Where-Object { $_ -cmatch $versionTagPattern }) + $tag = @(("v$number", $number) | Where-Object { $tags -ccontains $_ }) | Select-Object -First 1 + $at = if ($tag) { "refs/tags/$tag" } else { $Commit } + $sha = (& git rev-parse --verify --quiet "$at^{commit}") + if ($LASTEXITCODE -or -not $sha) { throw "$at isn't a commit in this clone." } + $lines = Get-ChangelogAt $sha + $previous = Get-PreviousVersionTag $number $versionTags + $section = if ($null -ne $lines) { Get-NewestRelease $lines $number } + if ($section) { + $text = $section.Notes + if (Test-EntryLayout $sha) { + $entry = Get-EntryNotes $sha $previous + if ($entry.Files.Count -or $entry.Unreleased.Count) { $text = Merge-ChangelogGroup (@($section.Notes) + $entry.Texts) } + } + } elseif (Test-EntryLayout $sha) { + $text = (Get-EntryNotes $sha $previous -All:($untracked -and -not ($null -ne $lines -and (Get-NewestRelease $lines)))).Notes + } elseif ($untracked -and $null -ne $lines) { + $text = Get-UnreleasedNotes $lines + } else { + throw "$changelogName at $sha has no section for $number, and the project keeps no entry files in changelog.d/: there are no notes to write." + } + if (-not "$text".Trim()) { throw "The notes for $number at $sha are empty: nothing to write." } + Set-Content -LiteralPath $Path -Value $text -Encoding utf8NoBOM + "Wrote the notes of $number, read at $(if ($tag) { "the tag $tag" } else { $sha }), to $Path." +} + # Whether GitHub has the release for $Version, or an error when it can't be told. function Test-GitHubRelease([string]$Version) { $answer = @(& $Gh api "repos/{owner}/{repo}/releases/tags/$Version" --silent 2>&1) @@ -451,14 +515,13 @@ function Find-ReleaseCommit([switch]$RequireCommit) { $tags = Get-RemoteTag '.' $versionTags = @($tags | Where-Object { $_ -cmatch $versionTagPattern }) $prefix = if ($versionTags.Count -and -not @($versionTags | Where-Object { $_ -like 'v*' }).Count) { '' } else { 'v' } - $preRelease = $landing.ContainsKey('pre-release') -and $landing['pre-release'] -eq 'untracked' $entries = Test-EntryLayout $tip $landed = $null $newest = Get-NewestRelease $lines if ($newest -and -not ($entries -and $tags -ccontains "$prefix$($newest.Number)")) { if ($newest.Number -notmatch '^[0-9]+\.[0-9]+\.[0-9]+\z') { Write-Host "$changelogName's newest release, $($newest.Number), isn't a release version such as 1.2.3: a release's version carries no prerelease label (the template's ADR-0075), so retitle the section to its version without one."; return } $number = $newest.Number - } elseif ($preRelease -or $entries) { + } elseif ($untracked -or $entries) { # The tag objects and, through ^{}, the commits the version tags name. $tagRefs = @(& git ls-remote --tags .) if ($LASTEXITCODE) { throw "Can't read the tags of . (git ls-remote exited $LASTEXITCODE)." } @@ -602,7 +665,8 @@ function Get-RegistryPublisher([string]$Root) { # Moves what releases published as entry files into the changelog (the template's ADR-0081): a section for each version # tag merged into HEAD whose entries are still in files, the entry files and `## [Unreleased]` lines it took in deleted, -# and the link lines. It writes the working tree only. +# and the link lines; under release: none also each entry file no release published, into [Unreleased] (ADR-0087). It +# writes the working tree only. function Invoke-ChangelogFold { [CmdletBinding(SupportsShouldProcess)] param() @@ -616,7 +680,6 @@ function Invoke-ChangelogFold { if ($LASTEXITCODE) { throw "Can't list the tags merged into HEAD (git tag exited $LASTEXITCODE)." } $versionTags = @($merged | Where-Object { $_ -cmatch $versionTagPattern } | Sort-Object { [version]($_ -replace '^v') }) $listed = @($lines | ForEach-Object { if ($_ -cmatch '^## \[?v?(?<number>[0-9]+\.[0-9]+\.[0-9]+)\]?( - \S+)?( \[YANKED\])?\s*\z') { $Matches.number } }) - $untracked = $landing.ContainsKey('pre-release') -and $landing['pre-release'] -eq 'untracked' $folds = [Collections.Generic.List[object]]::new() foreach ($tag in $versionTags) { @@ -631,15 +694,39 @@ function Invoke-ChangelogFold { $previous = Get-PreviousVersionTag $number $versionTags $folds.Add([pscustomobject]@{ Number = $number; Tag = $tag; Previous = $previous; Date = "$date".Trim(); Entry = (Get-EntryNotes $sha $previous) }) } - if (-not $folds.Count) { 'Nothing to fold.'; return } - $toDelete = @($folds | ForEach-Object { $_.Entry.Files } | Select-Object -Unique | Where-Object { $_ -cne $entryMarker -and (Test-Path -LiteralPath (Join-Path $root $_) -PathType Leaf) }) - "Releases to fold into ${changelogName}: $(($folds | ForEach-Object { $_.Tag }) -join ', '); entry files to delete: $(if ($toDelete.Count) { $toDelete -join ', ' } else { 'none' })." + # Under release: none no merge releases an entry file, so the fold also takes in each one no version tag released: + # one HEAD has and the newest counted version tag's commit lacks (the template's ADR-0087). + $pending = @() + if ($release -eq 'none') { + $head = (& git rev-parse --verify HEAD) + if ($LASTEXITCODE) { throw "Can't read HEAD (git rev-parse exited $LASTEXITCODE)." } + $counted = @($versionTags | Where-Object { -not ($untracked -and [version]($_ -replace '^v') -lt [version]'1.0.0') }) + $newestTag = if ($counted.Count) { $counted[$counted.Count - 1] } else { '' } + $atHead = @(& git ls-tree --name-only $head -- changelog.d/) + if ($LASTEXITCODE) { throw "Can't read the tree of HEAD (git ls-tree exited $LASTEXITCODE)." } + $released = @() + if ($newestTag) { + $released = @(& git ls-tree --name-only "refs/tags/$newestTag" -- changelog.d/) + if ($LASTEXITCODE) { throw "Can't read the tree of $newestTag (git ls-tree exited $LASTEXITCODE)." } + } + $foldedFiles = @($folds | ForEach-Object { $_.Entry.Files }) + $pending = [string[]]@($atHead | Where-Object { $_ -cmatch $entryFilePattern -and $_ -cne $entryMarker -and $released -cnotcontains $_ -and $foldedFiles -cnotcontains $_ -and (Test-Path -LiteralPath (Join-Path $root $_) -PathType Leaf) }) + if ($pending.Count) { $pending = Get-EntryOrder $head $newestTag $pending } + } + if (-not $folds.Count -and -not $pending.Count) { 'Nothing to fold.'; return } + + $toDelete = @(@($folds | ForEach-Object { $_.Entry.Files }) + @($pending) | Select-Object -Unique | Where-Object { $_ -cne $entryMarker -and (Test-Path -LiteralPath (Join-Path $root $_) -PathType Leaf) }) + if ($folds.Count) { + "Releases to fold into ${changelogName}: $(($folds | ForEach-Object { $_.Tag }) -join ', '); entry files to delete: $(if ($toDelete.Count) { $toDelete -join ', ' } else { 'none' })." + } + if ($pending.Count) { + "Entry files no release published, to fold into the [Unreleased] section of ${changelogName}, since AGENTS.md's Landing section says release: none: $($pending -join ', ')." + } # The lines under [Unreleased] that the folds took in. $taken = @($folds | ForEach-Object { $_.Entry.Unreleased }) - $at = -1 - for ($i = 0; $i -lt $lines.Count; $i++) { if ($lines[$i] -match '^## \[Unreleased\]') { $at = $i; break } } + $at = Find-UnreleasedHeading $lines if ($at -ge 0 -and $taken.Count) { $end = $lines.Count for ($i = $at + 1; $i -lt $lines.Count; $i++) { if ($lines[$i] -match '^## ' -or $lines[$i] -match '^\[[^\]]+\]:\s') { $end = $i; break } } @@ -689,7 +776,7 @@ function Invoke-ChangelogFold { for ($i = 0; $i -lt $lines.Count; $i++) { if ($lines[$i] -match '^\[(?<label>unreleased)\]:\s*(?<web>\S+?)/compare/\S+\.\.\.HEAD\s*$') { $unreleasedAt = $i; break } } - if ($unreleasedAt -ge 0) { + if ($unreleasedAt -ge 0 -and $folds.Count) { $label = $Matches.label $web = $Matches.web $listedVersions = @($lines | ForEach-Object { if ($_ -match '^\[v?(?<number>[0-9]+\.[0-9]+\.[0-9]+)\]:\s') { [version]$Matches.number } }) @@ -710,23 +797,50 @@ function Invoke-ChangelogFold { } } + if ($pending.Count) { + $texts = @($pending | ForEach-Object { Get-Content -LiteralPath (Join-Path $root $_) -Raw }) + $at = Find-UnreleasedHeading $lines + if ($at -lt 0) { + for ($i = 0; $i -lt $lines.Count; $i++) { if ($lines[$i] -match '^## ' -or $lines[$i] -match '^\[[^\]]+\]:\s') { $at = $i; break } } + if ($at -lt 0) { + while ($lines.Count -and $lines[$lines.Count - 1] -match '^\s*$') { $lines.RemoveAt($lines.Count - 1) } + if ($lines.Count) { $lines.Add('') } + $at = $lines.Count + } + $lines.InsertRange($at, [string[]]@('## [Unreleased]', '')) + } + $end = $lines.Count + for ($i = $at + 1; $i -lt $lines.Count; $i++) { if ($lines[$i] -match '^## ' -or $lines[$i] -match '^\[[^\]]+\]:\s') { $end = $i; break } } + $merged = Merge-ChangelogGroup (@($lines.GetRange($at + 1, $end - $at - 1) -join "`n") + $texts) + $lines.RemoveRange($at + 1, $end - $at - 1) + $lines.InsertRange($at + 1, [string[]](@('') + @($merged -split '\r?\n') + @(''))) + } + while ($lines.Count -and $lines[$lines.Count - 1] -match '^\s*$') { $lines.RemoveAt($lines.Count - 1) } if ($PSCmdlet.ShouldProcess($changelogName, 'Fold')) { [IO.File]::WriteAllText($path, (($lines -join $newline) + $newline), [Text.UTF8Encoding]::new($false)) foreach ($file in $toDelete) { Remove-Item -LiteralPath (Join-Path $root $file) } - "Folded $($folds.Count) release(s) into $changelogName." + if ($folds.Count) { "Folded $($folds.Count) release(s) into $changelogName." } + if ($pending.Count) { "Folded $($pending.Count) entry file(s) into the [Unreleased] section of $changelogName." } } } $root = (& git rev-parse --show-toplevel) if ($LASTEXITCODE) { throw 'Run this in a clone of the repository.' } $agents = Join-Path $root 'AGENTS.md' -if (-not (Test-Path -LiteralPath $agents)) { if ($Policy) { 'none' } else { Write-Note 'AGENTS.md is missing, so there is no release policy: nothing to publish.' }; exit 0 } -$landing = Get-LandingPolicy @(Get-Content -LiteralPath $agents) +if (-not (Test-Path -LiteralPath $agents) -and ($Policy -or -not ($Notes -or $Fold))) { if ($Policy) { 'none' } else { Write-Note 'AGENTS.md is missing, so there is no release policy: nothing to publish.' }; exit 0 } +$landing = if (Test-Path -LiteralPath $agents) { Get-LandingPolicy @(Get-Content -LiteralPath $agents) } else { @{} } $release = if ($landing.ContainsKey('release')) { $landing['release'] } else { 'none' } +# Whether AGENTS.md's Landing section says pre-release: untracked; every path reads this one value. +$untracked = $landing.ContainsKey('pre-release') -and $landing['pre-release'] -eq 'untracked' if ($release -notin 'none', 'tag', 'tag+release') { throw "AGENTS.md's Landing section says release: $release; use none, tag or tag+release." } if ($Policy) { $release; exit 0 } $changelogName = if ($landing.ContainsKey('changelog') -and $landing['changelog']) { $landing['changelog'] } else { 'CHANGELOG.md' } +if ($Notes) { + if (-not $OutFile) { throw '-Notes needs -OutFile, the file to write the notes to.' } + Write-VersionNote $Notes $OutFile + exit 0 +} if ($Fold) { Invoke-ChangelogFold; exit 0 } if ($release -eq 'none') { Write-Note "AGENTS.md's Landing section says release: none: nothing to publish."; exit 0 } @@ -737,7 +851,6 @@ $lines = @(Get-Content -LiteralPath $changelog) $sha = (& git rev-parse --verify --quiet "$Commit^{commit}") if ($LASTEXITCODE -or -not $sha) { throw "$Commit isn't a commit in this clone." } $planned = Get-PlannedRelease $sha -$untracked = $landing.ContainsKey('pre-release') -and $landing['pre-release'] -eq 'untracked' $newest = Get-NewestRelease $lines # Exits that need no tags come first, so a run with nothing to publish never reads the remote. if ($newest -and $newest.Number -notmatch '^[0-9]+\.[0-9]+\.[0-9]+\z') { "$changelogName's newest release, $($newest.Number), isn't a release version such as 1.2.3: a release's version carries no prerelease label (the template's ADR-0075), so retitle the section to its version without one."; exit 0 } diff --git a/.template/Update-Project.ps1 b/.template/Update-Project.ps1 index 0447b48..ed6cb42 100644 --- a/.template/Update-Project.ps1 +++ b/.template/Update-Project.ps1 @@ -1221,22 +1221,56 @@ function Get-DevContainerNote([object[]]$Changes) { ' The quickest way to start is the dev container: open the repository in a GitHub Codespace, or in VS Code with the Dev Containers extension, and [.devcontainer/devcontainer.json](.devcontainer/devcontainer.json) installs PowerShell 7 and the project''s tools and packages, so the commands below run as they are.' } +# The project's own scripts and workflows that read the changelog's [Unreleased] section, which misses the entries in +# changelog.d/ once plans write entry files (the template's ADR-0087): the tracked files of the kinds that hold code +# and have that text, leaving out .template/ and the template's files in $TemplateFiles. It runs in the project folder. +# It returns Files, the sorted paths, and Failure, which is empty, or says git ls-files failed, so no file was listed. +function Get-ChangelogNotesReader([string[]]$TemplateFiles) { + $tracked = @(& git -c core.quotePath=false ls-files -- '*.yml' '*.yaml' '*.ps1' '*.psm1' '*.sh' '*.js' '*.mjs' '*.cjs' '*.ts' '*.mts' '*.py' 2>$null) + $code = $LASTEXITCODE + if ($code) { $global:LASTEXITCODE = 0; return [pscustomobject]@{ Files = @(); Failure = "git ls-files exited $code" } } + [pscustomobject]@{ + Files = @($tracked | Where-Object { $_ -notlike '.template/*' -and $_ -notin $TemplateFiles -and (Test-Path -LiteralPath $_ -PathType Leaf) -and "$(Get-Content -LiteralPath $_ -Raw)" -cmatch '\[Unreleased\]' } | Sort-Object) + Failure = '' + } +} + # An update that adds changelog.d/README.md switches the project's plans to an entry file each (the template's -# ADR-0081), so it prints what changes. -function Get-ChangelogEntriesNote([object[]]$Changes) { +# ADR-0081), so it prints what changes; the paragraph follows the release policy, as a release: none project has no +# merge that releases. +function Get-ChangelogEntriesNote([object[]]$Changes, [string[]]$TemplateFiles) { if (-not ($Changes | Where-Object { $_.Kind -eq 'added' -and $_.File -eq 'changelog.d/README.md' })) { return } '' - 'This adds changelog.d/README.md: from now on each plan writes its changelog entries to a file of its own in changelog.d/ instead of editing the changelog, so plans that run at the same time don''t conflict on it, and the release a merge makes takes the version its pull request''s Release: line names, or the next free one, and its notes from those files (the template''s ADR-0081, in docs/decisions/project-template/). A plan written before this update still edits the changelog, and lands and releases as before. ./.template/Publish-Release.ps1 -Fold, run in a pull request of its own, writes each published release''s entries into the changelog as its section; a template update''s plan runs it.' + if ((Get-ReleasePolicyAnswer) -in 'tag', 'tag+release') { + 'This adds changelog.d/README.md: from now on each plan writes its changelog entries to a file of its own in changelog.d/ instead of editing the changelog, so plans that run at the same time don''t conflict on it, and the release a merge makes takes the version its pull request''s Release: line names, or the next free one, and its notes from those files (the template''s ADR-0081, in docs/decisions/project-template/). A plan written before this update still edits the changelog, and lands and releases as before. ./.template/Publish-Release.ps1 -Fold, run in a pull request of its own, writes each published release''s entries into the changelog as its section; a template update''s plan runs it.' + } + else { + 'This adds changelog.d/README.md: from now on each plan writes its changelog entries to a file of its own in changelog.d/ instead of editing the changelog, so plans that run at the same time don''t conflict on it (the template''s ADR-0081 and ADR-0087, in docs/decisions/project-template/). AGENTS.md''s Landing section says release: none, so no merge makes a release and no plan has a Release: line: ./.template/Publish-Release.ps1 -Fold, run in a pull request of its own, writes the entry files no release published into the changelog''s [Unreleased] section and deletes them; a template update''s plan runs it. To release by hand, tag the default branch''s commit first, write the release''s notes with ./.template/Publish-Release.ps1 -Notes <version> -OutFile <file> and publish them, such as with gh release create <version> --verify-tag --notes-file <file>, then run ./.template/Publish-Release.ps1 -Fold in a pull request of its own, which writes the release''s section into the changelog. A plan written before this update still edits the changelog.' + } + $readers = Get-ChangelogNotesReader $TemplateFiles + if ($readers.Failure) { + '' + "The project's own files couldn't be listed ($($readers.Failure)), so the update didn't look for scripts or workflows of its own that read the changelog's [Unreleased] section. Where one writes a release's notes, have it read them with ./.template/Publish-Release.ps1 -Notes <version> -OutFile <file> (the template's ADR-0087)." + } + elseif ($readers.Files.Count) { + '' + "These files of the project's own read the changelog's [Unreleased] section, which from now on lacks the entries in changelog.d/: $($readers.Files -join ', '). Where one writes a release's notes, have it read them with ./.template/Publish-Release.ps1 -Notes <version> -OutFile <file>, which takes the entry files and the changelog by the template's rule (ADR-0087), instead of reading the changelog itself." + } } # codeql.yml is project-owned, so an update can only name the change that keeps CodeQL out of a private repository (the # template's ADR-0056). It looks for the condition that skips the Analyze jobs, an if: line that names # needs.languages.outputs.public, so a visibility read that appears only in a comment doesn't count. -function Get-CodeQLVisibilityNote { +# A public repository, as Get-RepositoryVisibility reads it, gets no note: CodeQL runs there, so a workflow without the +# condition, such as a CodeQL workflow of the project's own (ADR-0047), needs nothing. +function Get-CodeQLVisibilityNote([string]$Repository) { if (-not (Test-Path -LiteralPath .github/workflows/codeql.yml -PathType Leaf)) { return } if ((Get-Content -LiteralPath .github/workflows/codeql.yml -Raw) -match '(?m)^\s+if:.*\bneeds\.languages\.outputs\.public\b') { return } + $visibility = Get-RepositoryVisibility $Repository + if ($visibility.Private -eq $false) { return } + $where = if ($visibility.Private) { 'this repository is private' } else { "GitHub couldn't say whether this repository is private ($($visibility.Reason))" } '' - '.github/workflows/codeql.yml runs in a private repository too, where GitHub Free offers no code scanning, so its Analyze jobs fail on every push (the template''s ADR-0056, in docs/decisions/project-template/). The file is the project''s, so the update leaves it as it is: copy the template''s change to it, the languages job''s step "Read whether the repository is public" and its public output, and if: needs.languages.outputs.public == ''true'' on each Analyze job. A skipped job passes, so the check stays green in a private repository, and CodeQL runs as before in a public one.' + ".github/workflows/codeql.yml has no condition that skips its Analyze jobs in a private repository, and ${where}: in a private repository GitHub Free offers no code scanning, so those jobs fail on every push (the template's ADR-0056, in docs/decisions/project-template/). The file is the project's, so the update leaves it as it is: copy the template's change to it, the languages job's step `"Read whether the repository is public`" and its public output, and if: needs.languages.outputs.public == 'true' on each Analyze job. A CodeQL workflow of the project's own without a languages job (the template's ADR-0047) takes the same step into a job its analysis jobs need, and the same condition on each of them. A skipped job passes, so the check stays green in a private repository, and CodeQL runs as before in a public one." } # The *.cs files under the current folder that don't start with the header .editorconfig's file_header_template sets, @@ -1985,7 +2019,7 @@ try { # A success ends with exit 0, not return, which would hand a caller that runs this with & the exit code of the last # git command, such as git apply --check's 1 for a hunk the project lacks. - if (-not (git status --porcelain)) { "Already up to date: template $to."; Get-ReleasePolicyNote; Get-LicenseWarning; Get-BadgeReminder; Get-ReadmeNote; Get-ImmutableReleaseNote $false; Get-CodeReviewNote $originRepository; Get-CodeQLVisibilityNote; exit 0 } + if (-not (git status --porcelain)) { "Already up to date: template $to."; Get-ReleasePolicyNote; Get-LicenseWarning; Get-BadgeReminder; Get-ReadmeNote; Get-ImmutableReleaseNote $false; Get-CodeReviewNote $originRepository; Get-CodeQLVisibilityNote $originRepository; exit 0 } "Template $from -> ${to}:" $changes | Sort-Object Kind, File | ForEach-Object { ' {0,-9} {1}' -f $_.Kind, $_.File } # A file the update leaves as the project had it lost nothing, such as a local edit the new version also makes or a @@ -2113,7 +2147,7 @@ try { Get-CiCallNote Get-CiPermissionNote Get-ReleaseLineDocNote - Get-CodeQLVisibilityNote + Get-CodeQLVisibilityNote $originRepository $offered = [bool]@($shown | Where-Object { $_.File -eq 'SECURITY.md' } | ForEach-Object Lines | Where-Object { $_ -match '^\s*\+Releases are immutable' }).Count Get-ImmutableReleaseNote $offered Get-CodeReviewNote $originRepository @@ -2179,7 +2213,7 @@ try { Get-CodeQLWorkflowNote $changes $originRepository Get-BaselineNote $originRepository Get-DevContainerNote $changes - Get-ChangelogEntriesNote $changes + Get-ChangelogEntriesNote $changes $ownable Get-ContributionsNote $contributionsBefore if ($visibility -and $null -eq $visibility.Private) { $written = @($visibilityFiles | Where-Object { Test-Path -LiteralPath $_ }); if ($written) { Get-VisibilityNote $visibility.Reason $written } } Get-LicenseWarning diff --git a/changelog.d/20261204-template-update-v0.166.0.md b/changelog.d/20261204-template-update-v0.166.0.md new file mode 100644 index 0000000..aef76fb --- /dev/null +++ b/changelog.d/20261204-template-update-v0.166.0.md @@ -0,0 +1,6 @@ +### Changed + +- The repository follows project-template v0.166.0, whose + `.template/Publish-Release.ps1 -Notes <version> -OutFile <file>` writes a release's notes from the changelog and + the entry files in `changelog.d/` + ([ADR-0087](docs/decisions/project-template/0087-notes-come-from-publish-release-and-release-none-folds-every-entry-file.md)). diff --git a/changelog.d/README.md b/changelog.d/README.md index 366d2e7..b2fdbaa 100644 --- a/changelog.d/README.md +++ b/changelog.d/README.md @@ -1,12 +1,14 @@ # Changelog Entries -Each plan writes its changelog entries to a file of its own in this folder instead of editing the changelog, so plans that run at the same time don't conflict on it (the template's ADR-0081, in `docs/decisions/project-template/`). +Each plan writes its changelog entries to a file of its own in this folder instead of editing the changelog, so plans that run at the same time don't conflict on it (the template's ADR-0081 and ADR-0087, in `docs/decisions/project-template/`). - A plan's file is `changelog.d/<date>-<name>.md`: `<date>` is the day the plan writes it, in UTC, as `yyyyMMdd`, and `<name>` is its branch's name without a leading `worktree-`, with each `/` written as `-`, such as `20261202-issue-42.md`. The date sorts this folder; the branch name keeps the file apart from another plan's. - It holds the plan's entries under the Keep a Changelog headings `### Added`, `### Changed`, `### Deprecated`, `### Removed`, `### Fixed` and `### Security`, in that order and each once, each entry a `- ` line written as it would be in the changelog, its links relative to the repository's root. - It has no `##` heading, no version and no link reference definitions. -- When the plan's pull request merges, `.template/Publish-Release.ps1` publishes the release with the entries the merge added as its notes, under the version the pull request's `Release:` line names, or the next free one. +- Under `release: tag` or `tag+release` in `AGENTS.md`'s Landing section, when the plan's pull request merges, `.template/Publish-Release.ps1` publishes the release with the entries the merge added as its notes, under the version the pull request's `Release:` line names, or the next free one. - A release lists its entries in the order their files reached the default branch, whatever the files' names. - `.template/Publish-Release.ps1 -Fold`, run in a pull request of its own, writes the entries of each published release into the changelog as that release's section and deletes their files. A template update's plan runs it. +- `.template/Publish-Release.ps1 -Notes <version> -OutFile <file>` writes a version's notes by the same rule, from this folder and the changelog, and tags and publishes nothing. A workflow or script of the project's own that publishes a release reads its notes this way, never from the changelog alone, which lacks the entries still in this folder. +- Under `release: none`, no merge makes a release, so `-Fold` also writes each entry file no release published into the changelog's `## [Unreleased]` and deletes it. To release by hand, tag the default branch's commit first, write the release's notes with `-Notes` and publish them, such as with `gh release create <version> --verify-tag --notes-file <file>`, then run `-Fold` in a pull request of its own, which writes the release's section. This file is template-owned: a template update replaces it. diff --git a/docs/decisions/project-template/0081-changelog-entries-are-a-file-per-plan-and-the-merge-settles-the-version.md b/docs/decisions/project-template/0081-changelog-entries-are-a-file-per-plan-and-the-merge-settles-the-version.md index 50f4570..3f1c04c 100644 --- a/docs/decisions/project-template/0081-changelog-entries-are-a-file-per-plan-and-the-merge-settles-the-version.md +++ b/docs/decisions/project-template/0081-changelog-entries-are-a-file-per-plan-and-the-merge-settles-the-version.md @@ -1,6 +1,6 @@ # 0081. A plan's changelog entries are a file of its own, and its merge settles its version -- **Status:** Accepted +- **Status:** Accepted (amended by 0087) - **Date:** 2026-12-02 - **Amends:** 0015, 0016, 0032 diff --git a/docs/decisions/project-template/0087-notes-come-from-publish-release-and-release-none-folds-every-entry-file.md b/docs/decisions/project-template/0087-notes-come-from-publish-release-and-release-none-folds-every-entry-file.md new file mode 100644 index 0000000..633a119 --- /dev/null +++ b/docs/decisions/project-template/0087-notes-come-from-publish-release-and-release-none-folds-every-entry-file.md @@ -0,0 +1,83 @@ +# 0087. A version's notes come from Publish-Release.ps1, and under release: none the fold takes in every entry file + +- **Status:** Accepted +- **Date:** 2026-12-03 +- **Amends:** 0081 + +## Context + +[ADR-0081](0081-changelog-entries-are-a-file-per-plan-and-the-merge-settles-the-version.md) left one reader that turns +entry files into notes, `.template/Publish-Release.ps1`, which applies its decision 3 only when it publishes the GitHub +release itself (`release: tag+release`), and one writer of the changelog, `-Fold`, which writes a section only for a +version tag whose entries are still in files. Three projects updating from v0.162.0 to v0.165.0 found the gaps: + +- NCodeGroup/brand (`release: tag`, pre-release) writes its notes in its own `publish.yml` with + `tools/release-notes.mjs` from `CHANGELOG.md`, and had to copy decision 3, ordering the files by name where decision 3 + orders them by when they reached the default branch + ([#773](https://github.com/NCodeGroup/project-template/issues/773)). +- NCodeGroup/identity-platform (`release: none`, tagged by hand) moved `## [Unreleased]` into a section before tagging, + and nothing said how a hand release gets its notes once they are files + ([#772](https://github.com/NCodeGroup/project-template/issues/772)). +- NCodeGroup/.github (`release: none`, never tagged) has no tag to move its files, so `CHANGELOG.md` stops at the update + and `-Fold -WhatIf` always prints `Nothing to fold.`, so no template update folds + ([#771](https://github.com/NCodeGroup/project-template/issues/771)). + +## Decision + +1. Notes: `.template/Publish-Release.ps1 -Notes <version> -OutFile <file>` writes the version's notes by decision 3 and + tags and publishes nothing, under any release policy. It reads at the commit of the version's tag when the clone has + it, else at `-Commit`; the clone's own tags count (a checkout with `fetch-depth: 0` has them); empty notes fail. A + project's own publishing workflow, and a person who releases by hand, read a release's notes this way, never from the + changelog alone and never with a copy of the rule. +2. The update that adds `changelog.d/README.md` names each tracked script or workflow of the project's own (`.yml`, + `.yaml`, `.ps1`, `.psm1`, `.sh`, `.js`, `.mjs`, `.cjs`, `.ts`, `.mts`, `.py`, outside `.template/` and the template's + files) whose text has `[Unreleased]`, and says to read the notes with `-Notes`. When the project's files can't be + listed, it says so and names `-Notes` all the same. +3. Under `release: none` plans still write entry files, and `changelog-entries` stays `files`: plans that run at once + conflict on `[Unreleased]` under every policy. +4. Under `release: none`, `-Fold` also takes in each entry file no release published, one HEAD has and the newest + counted version tag's commit lacks (no tag below 1.0.0 counts in a `pre-release: untracked` project), merges it into + `## [Unreleased]` under one heading per group, in the order the files reached the default branch, and deletes it. A + template update's plan runs it whenever `-Fold -WhatIf` names something, and a person may run it at any time, in a + pull request of its own. Under `tag` and `tag+release` the fold is unchanged: an untagged entry file is the next + release's notes. +5. A hand release under `release: none` tags the default branch's commit, writes its notes with `-Notes` and publishes + them (such as `gh release create <version> --verify-tag --notes-file <file>`), then runs `-Fold` in a pull request of + its own, which writes the release's section from the entry files and `[Unreleased]` lines the tag took in, whichever + an earlier fold moved. +6. Under `release: none` the update notice says 3 to 5 instead of naming a merge's release and a `Release:` line; + `changelog.d/README.md` says them too. A project without `AGENTS.md`, or whose Landing section has no `release:` + line, is under `release: none`: its update notice says 3 to 5, and `-Notes` and `-Fold` run as they do under + `release: none`. + +## Options considered + +- `changelog-entries: changelog` under `release: none`. Rejected: plans conflict on `[Unreleased]` again, which is + ADR-0081's reason, and a project that moves to `tag` would switch layouts. +- Record that such a project's changelog is `changelog.d/` plus `CHANGELOG.md`. Rejected: the changelog never catches + up, and every reader of it misses each plan since the update. +- Fold untagged files into `[Unreleased]` under every release policy. Rejected: under `tag` and `tag+release` they are + already the next release's notes, and [#771](https://github.com/NCodeGroup/project-template/issues/771) leaves those + policies as they are. +- Each project copies decision 3 into its own tool. Rejected: copies drift, as brand's orders by name. +- `-Notes` reads the remote's tags. Rejected: a private repository's workflow would need credentials for + `git ls-remote`, and `-Find` and `-Fold` already count the clone's. +- `-Notes` and the fold under `release: none` (chosen). + +## Consequences + +- A project's own publishing workflow calls `-Notes` and drops its copy of the rule. +- A `release: none` project's changelog catches up at each fold. +- A hand release's notes exist as soon as it is tagged. +- Under `release: none` the fold writes `[Unreleased]`, while a plan's pull request still only adds an entry file, so + the two never conflict. +- An entry file that an older plan's untagged section released stays in `changelog.d/` under every policy until a person + moves it, as ADR-0081 says. + +## References + +- `.template/Publish-Release.ps1`, `.template/Update-Project.ps1` and `changelog.d/README.md` +- [ADR-0081](0081-changelog-entries-are-a-file-per-plan-and-the-merge-settles-the-version.md) +- [#771](https://github.com/NCodeGroup/project-template/issues/771), + [#772](https://github.com/NCodeGroup/project-template/issues/772) and + [#773](https://github.com/NCodeGroup/project-template/issues/773) diff --git a/docs/decisions/project-template/README.md b/docs/decisions/project-template/README.md index 4c848d5..32ea2b1 100644 --- a/docs/decisions/project-template/README.md +++ b/docs/decisions/project-template/README.md @@ -93,12 +93,13 @@ never brings a number the project already uses | [0078](0078-the-epic-runner-is-a-bounded-reconcile-pass-over-state-on-github.md) | `/run-epic` is an idempotent reconcile pass that advances each story by at most one action, over state on GitHub with the epic's status comment as its view, run by one host session with a worker per repository where the tool has child sessions, within bounds: work the project's own people filed, two stories in progress per repository, a fix and time budget, the `autopilot: stop` label and protected paths only through a story's own plan | | [0079](0079-a-run-epic-worker-acts-once-a-person-confirms-the-run-in-its-session.md) | In a Claude Code cloud session, `/run-epic` starts each worker with a request in words; a worker acts only once its user's own message in its session confirms the run, once for each coordinating session; the pass names a waiting worker and the sentence to send it at once, never gives a worker its user's authority another way, and takes the action itself when `create_session` starts no worker | | [0080](0080-a-push-workflow-that-doesnt-run-on-a-merge-commit-stops-the-line.md) | A workflow whose `push` trigger takes the default branch's newest commit, by its branch and path filters, and that has no run on it two hours after the commit reached the branch stops the line and never counts as passed; no agent reverts the merge or starts the run for it, and a commit no workflow watches still counts as passed then (amends 0067) | -| [0081](0081-changelog-entries-are-a-file-per-plan-and-the-merge-settles-the-version.md) | Each plan writes its changelog entries to a file of its own in `changelog.d/`; a merge's release takes the version its pull request's `Release:` line names, or the next free one, and its notes from those files; `Publish-Release.ps1 -Fold`, in a pull request of its own, moves published entries into the changelog; a list every plan adds to at one place becomes a file per item, as the template's decision index rows do, and `/ship-plan` renumbers a decision record whose number another plan took (amends 0015, 0016 and 0032) | +| [0081](0081-changelog-entries-are-a-file-per-plan-and-the-merge-settles-the-version.md) | Each plan writes its changelog entries to a file of its own in `changelog.d/`; a merge's release takes the version its pull request's `Release:` line names, or the next free one, and its notes from those files; `Publish-Release.ps1 -Fold`, in a pull request of its own, moves published entries into the changelog; a list every plan adds to at one place becomes a file per item, as the template's decision index rows do, and `/ship-plan` renumbers a decision record whose number another plan took (amends 0015, 0016 and 0032; amended by 0087) | | [0082](0082-a-charts-check-takes-its-ci-values-and-the-crds-it-needs.md) | `helm-chart.yml` lints each chart with each of its `ci/*-values.yaml` files, or its default values when it has none, and dry-runs it with them after applying the CRDs in its `ci/crds/` folder, so a chart whose schema requires values or whose templates need CRDs keeps the template-owned check (amends 0076) | | [0083](0083-a-project-can-hold-a-release-to-anonymous-pulls-of-its-images-and-charts.md) | With the `public_packages` answer, a public repository's release fails when a consumer without a registry login can't verify an image's signature, or pull a chart and verify its signature; without it, the image check only warns and charts aren't checked anonymously (amends 0071, 0073 and 0076) | | [0084](0084-a-merge-queues-codeql-run-analyzes-nothing.md) | `codeql.yml` keeps its `merge_group` trigger but skips its `CodeQL languages` job there, and so its `Analyze` jobs: the code-scanning rule doesn't apply to a merge group, the `push` run analyzes the same merge commit, and an upload after the queue deletes its ref fails and stops the line (amends 0044 and 0047) | | [0085](0085-an-attestation-writes-no-artifact-storage-record.md) | Each attest step in `publish-image.yml` and `publish-chart.yml` that pushes its attestation to the registry passes `create-storage-record: false`, so it writes no artifact metadata storage record and no job needs `artifact-metadata: write` (amends 0073 and 0076) | | [0086](0086-a-token-permissions-alert-for-a-write-the-scorecard-record-lists-is-dismissed.md) | ADR-0020's Token-Permissions row lists every job-level write the template's workflows grant, with its reason, and the project template's `tools/Dismiss-ScorecardAlerts.ps1` dismisses each open Token-Permissions alert for one of them as won't fix with a standard comment, whatever the number of writers; any other stays open (amends 0020 and 0035) | +| [0087](0087-notes-come-from-publish-release-and-release-none-folds-every-entry-file.md) | `Publish-Release.ps1 -Notes <version> -OutFile <file>` writes a version's notes by ADR-0081's rule for a project's own publishing workflow or a release made by hand; under `release: none`, `-Fold` also folds the entry files no release published into `## [Unreleased]`, and a hand release is tagged first, then folded in a pull request of its own (amends 0081) | ## .NET