Skip to content

ops(scripts): auto-stamp ms.date in CHANGELOG.md from release-please workflow #645

@WilliamBerryiii

Description

@WilliamBerryiii

Background

Follow-up to #644, which excluded CHANGELOG.md from the changed-files ms.date freshness check (scripts/linting/Invoke-MsDateFreshnessCheck.ps1) so release-please PRs are not blocked by a stale frontmatter date. That fix is correct but defensive — the underlying issue is that release-please does not refresh ms.date when it regenerates CHANGELOG.md.

Proposal (Option 1)

Add a step to the release workflow that runs after googleapis/release-please-action and, when a release PR was opened or updated, rewrites the ms.date frontmatter field in CHANGELOG.md and pushes the change back to the release PR branch.

Sketch:

- uses: googleapis/release-please-action@v4
  id: release
  with:
    config-file: release-please-config.json
    manifest-file: release-please-manifest.json

- name: Stamp ms.date in CHANGELOG.md
  if: steps.release.outputs.prs_created == 'true' || steps.release.outputs.pr != ''
  env:
    PR_BRANCH: ${{ fromJSON(steps.release.outputs.pr).headBranchName }}
  run: |
    git fetch origin "$PR_BRANCH"
    git checkout "$PR_BRANCH"
    today=$(date -u +%Y-%m-%d)
    sed -i -E "s/^ms\.date: .*/ms.date: ${today}/" CHANGELOG.md
    git config user.name  "github-actions[bot]"
    git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
    git add CHANGELOG.md
    git diff --cached --quiet || git commit -m "chore: refresh CHANGELOG ms.date"
    git push origin "$PR_BRANCH"

Acceptance Criteria

  • Release-please PRs land with ms.date in CHANGELOG.md set to the date the PR was last regenerated (UTC).
  • The release workflow handles the no-op case (no release PR open) without failing.
  • The commit-back step uses the github-actions[bot] identity and a conventional commit message so it does not pollute the changelog itself.
  • Once verified working, consider removing the CHANGELOG.md entry from $excludePatterns in scripts/linting/Invoke-MsDateFreshnessCheck.ps1 so the freshness check covers the changelog again.

Alternatives Considered

  • Option 2 — release-please custom updater plugin. Heavier than warranted for a single frontmatter field.
  • Option 3 — drop ms.date from CHANGELOG.md entirely. Viable if the docs pipeline does not require the field on generated files; per-release headers already encode dates.

References

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions