Skip to content

Use GITHUB_REPOSITORY as the default repo when no repo option is configured in changelog-github - #1871

Merged
Andarist merged 9 commits into
changesets:mainfrom
mihkeleidast:issue/1870
Jun 26, 2026
Merged

Use GITHUB_REPOSITORY as the default repo when no repo option is configured in changelog-github#1871
Andarist merged 9 commits into
changesets:mainfrom
mihkeleidast:issue/1870

Conversation

@mihkeleidast

@mihkeleidast mihkeleidast commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

Fixes #1870.

Makes the changelog generator options object fully optional, as the env variable is defined in GitHub Actions.

Less configuring, simpler to use.

@changeset-bot

changeset-bot Bot commented Mar 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: bf475c6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@changesets/changelog-github Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov

codecov Bot commented Mar 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.04%. Comparing base (6c79210) to head (bf475c6).

Files with missing lines Patch % Lines
packages/changelog-github/src/index.ts 87.50% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1871      +/-   ##
==========================================
+ Coverage   85.49%   86.04%   +0.55%     
==========================================
  Files          70       70              
  Lines        2550     2558       +8     
  Branches      687      693       +6     
==========================================
+ Hits         2180     2201      +21     
+ Misses        339      330       -9     
+ Partials       31       27       -4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines +244 to +253
process.env.GITHUB_REPOSITORY = data.repo;
const [changeset, bump] = getChangeset("fixes #1234 and #5678", data.commit);
expect(await getReleaseLine(changeset, bump, null)).toMatchInlineSnapshot(`
"

- [#1613](https://github.com/emotion-js/emotion/pull/1613) [\`a085003\`](https://github.com/emotion-js/emotion/commit/a085003) Thanks [@Andarist](https://github.com/Andarist)! - something
fixes [#1234](https://github.com/emotion-js/emotion/issues/1234) and [#5678](https://github.com/emotion-js/emotion/issues/5678)"
`);

process.env.GITHUB_REPOSITORY = undefined;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please wrap this in try/catch so the env variable gets reverted correctly. Ideally, we should do this using a helper like this:

function setEnvironmentVariable(name: string, value: string | undefined) {
  const hadValue = Object.hasOwn(process.env, name);
  const originalValue = process.env[name];

  if (typeof value === "string") {
    process.env[name] = value;
  } else {
    delete process.env[name];
  }

  return () => {
    if (hadValue) {
      process.env[name] = originalValue;
    } else {
      delete process.env[name];
    }
  };
}

Feel free to add it to the test-utils

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Should be done if I understood you correctly.

Comment thread packages/changelog-github/src/index.ts Outdated
'Please provide a repo to this changelog generator like this:\n"changelog": ["@changesets/changelog-github", { "repo": "org/repo" }]'
);
}
const { GITHUB_REPOSITORY } = readEnv(options);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's not couple options.repo with env. Please introduce a new util called smth like resolveRepository

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done!

Comment thread .changeset/big-lions-occur.md Outdated
@Andarist Andarist changed the title Use repo name from GITHUB_REPOSITORY env variable Use GITHUB_REPOSITORY as the default repo when no repo option is configured in changelog-github Jun 26, 2026
@Andarist
Andarist enabled auto-merge June 26, 2026 07:06
@Andarist
Andarist added this pull request to the merge queue Jun 26, 2026
Merged via the queue into changesets:main with commit dfefc4e Jun 26, 2026
12 checks passed
@bluwy bluwy mentioned this pull request Jun 30, 2026
1 task
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.

changelog-github - infer repo name from environment variables

2 participants