Skip to content

Add shared changelog extractor and fix integrity regex - #3090

Draft
jekloudaMSFT wants to merge 1 commit into
mainfrom
pr1-changelog-util
Draft

Add shared changelog extractor and fix integrity regex#3090
jekloudaMSFT wants to merge 1 commit into
mainfrom
pr1-changelog-util

Conversation

@jekloudaMSFT

Copy link
Copy Markdown
Collaborator

For more information about how to contribute to this repo, visit this page.

Description

This is the first of four stacked PRs that streamline the TeamsJS release pipeline by automating the current manual release checklist and GitHub Release creation. This foundational PR contains no workflow/behavior changes — it extracts shared logic and fixes two latent bugs, so the later PRs (validation library, validate workflow, orchestrate workflow) can build on it.

Main changes in the PR:

  1. Add tools/cli/extract-changelog-section.js - a shared, importable module that returns the changelog body for a given version. It matches the ## header exactly, fixing a latent bug in the previous  startsWith -based logic where requesting 2.53.1 could match the 2.53.10 section (and vice-versa). Reused by the validation scripts and workflows introduced in later PRs.
  2. Refactor tools/cli/readChangelog.js to delegate to the new shared extractor (behavior-preserving; keeps the existing  prerelease.yml  workflow working).
  3. Fix the integrity-replacement regex in tools/cli/preRelease.js - add the global ( /g ) flag to /integrity=".*?"/ so every integrity="..." attribute in a file is updated during a release, not just the first. Previously a file with more than one integrity attribute would ship a stale SRI hash on all but the first.

Validation

Validation performed:

  1. Ran the extractor against the real changelog:  node tools/cli/extract-changelog-section.js 2.53.1 returns the correct, isolated section.
  2. Verified the prefix-collision fix:  2.53.1 and 2.53.10 each return only their own section.
  3. Confirmed readChangelog.js  output is unchanged after the refactor.
  4. Confirmed the preRelease.js regex now replaces all integrity occurrences (covered by tests in PR 2).

Unit Tests added:

No — the unit tests that cover this module (extract-changelog-section , including the prefix-collision and missing-version cases) live in stacked PR 2, which registers tools/cli as a workspace package and adds the Jest harness. Splitting them out keeps this PR to a minimal, low-risk refactor. The tests fully exercise the code introduced here.

End-to-end tests added:

No — no runtime/product behavior changes; these are release-tooling scripts.

Additional Requirements

Change file added:

No — changes are limited to repo release tooling under tools/cli/ and produce no @microsoft/teams-js package changes, so no beachball change file is required.

Related PRs:

Part of a stacked series:

• PR 1 (this) — shared changelog extractor + bug fixes
• PR 2 — validation scripts + Jest tests
• PR 3 —  release-validate.yml  workflow
• PR 4 —  release-orchestrate.yml  (auto pre-release)

Next/remaining steps:

• PR 2: release integrity + SRI validation library, with fixture-based unit tests
• PR 3: PR validation workflow (back required status checks on release/* )
• PR 4: automate GitHub pre-release creation on release-PR merge

Extract the changelog-section logic into tools/cli/extract-changelog-section.js
with exact version-header matching (fixes a latent startsWith bug where 2.53.1
matched 2.53.10) and refactor readChangelog.js to reuse it. Also make the
preRelease.js integrity replacement global so every integrity attribute is
updated, not just the first.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 57d4bec2-3b60-423f-8ca2-34bc2da0d3c3
Copilot AI review requested due to automatic review settings July 16, 2026 21:01
@jekloudaMSFT
jekloudaMSFT requested a review from a team as a code owner July 16, 2026 21:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a reusable changelog-section extraction utility to support upcoming release-pipeline automation work, refactors the existing readChangelog CLI to use it, and fixes a latent integrity-attribute replacement bug in pre-release tooling.

Changes:

  • Introduce tools/cli/extract-changelog-section.js to extract a specific ## <version> section from the TeamsJS changelog without prefix-collision.
  • Refactor tools/cli/readChangelog.js to delegate to the shared extractor.
  • Update tools/cli/preRelease.js to replace all integrity="..." occurrences (global regex) instead of only the first.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
tools/cli/readChangelog.js Delegates changelog section output to the shared extractor module.
tools/cli/preRelease.js Fixes integrity-attribute replacement to update every occurrence in a file.
tools/cli/extract-changelog-section.js New shared module/CLI for extracting changelog sections by exact version header.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (index === -1) {
throw new Error(`Matching version ${version} in changelog was not found`);
}
return parts[index + 1] ? parts[index + 1].trim() : '';
@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
packages/teams-js/dist/esm/packages/teams-js/src/index.js 203.98 KB (0%) 4.1 s (0%) 452 ms (+28.89% 🔺) 4.6 s

@jekloudaMSFT
jekloudaMSFT marked this pull request as draft July 16, 2026 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants