Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates changeset config to beautify CHANGELOG.md #36

Merged
merged 2 commits into from
Jan 10, 2024

Conversation

arthurgousset
Copy link
Contributor

@arthurgousset arthurgousset commented Jan 5, 2024

Description

Uses the @changesets/changelog-github plugin to beautify our CHANGELOG.md as described in the changeset docs.

Before

Currently, our CHANGELOG.md looks like this:

3.1.3

Patch Changes

  • 041fc92: Add textual feedback about parsing proposal

Source: cli/CHANGELOG.md

After

After this PR, the CHANGELOG.md will adds links to commits, include a thank-you message to the person who added the changeset, and link to the relevant PR.

For example:

1.4.5

Patch Changes

  • #282 eb19e25 Thanks @mark-omarov! - Updated a few dependencies to patch the security vulnerabilities that were reported for their older versions.

Source: changeset/action

2.0.0

Major Changes

Source: viem

Additional info

I found out how to do this thanks to this Github Discussion:

The changelog configuration is as follows:

{
  "changelog": ["@changesets/changelog-github", { "repo": "<org>/<repo>" }]
}

Source: changeset docs

Our config follows the pattern seen in:

How the plugin works and how changeset formats the changelog is described here: changesets > docs > Modifying The Changelog Formats

Tested

  • Not yet. Hoping I can test this before merging to master.

Related issues

Backwards compatibility

No breaking change

Documentation

No public facing docs required, changeset is unchanged.

Uses the `@changesets/changelog-github` package to beautify our changelog.
Copy link

changeset-bot bot commented Jan 5, 2024

⚠️ No Changeset found

Latest commit: a43d477

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@arthurgousset arthurgousset requested review from aaronmgdr and a team January 5, 2024 18:44
@arthurgousset arthurgousset self-assigned this Jan 5, 2024
@arthurgousset arthurgousset marked this pull request as ready for review January 5, 2024 18:55
Copy link

New dependencies detected. Learn more about Socket for GitHub ↗︎

Packages Version New capabilities Transitives Size Publisher
@changesets/changelog-github 0.5.0 network, environment +4 307 kB changesets-release-bot

@arthurgousset
Copy link
Contributor Author

arthurgousset commented Jan 5, 2024

I'm stuck trying to test this in the developer-tooling repo without bumping package versions on NPM.

One idea I had is to use an empty changeset with yarn add changeset --empty and running changeset version to generate a changelog as described here:

I couldn't find any changesets in the .changeset/ folder to generate the changelog. Perhaps that's because this is a brand-new repo. Or maybe I'm missing something?

Does anyone have ideas how we could assert that this PR generates the CHANGELOG we are interested in?

@aaronmgdr
Copy link
Member

aaronmgdr commented Jan 8, 2024

no changesets because no changes since last release.

to verify you could branch off of here. write a bogus changeset. run yarn cs version. and check the output. and just not merge that back in anywhere

@arthurgousset
Copy link
Contributor Author

arthurgousset commented Jan 8, 2024

Great idea! I'm doing that here:

INFO
I needed two branches because user tagging only happens when PRs are merged into a branch. Not when a commit is made on a branch directly. So I merged a bogus PR into the bogus branch to test this.

It looks like we need slightly elevated "read" permissions on Github:

Please create a GitHub personal access token at https://github.com/settings/tokens/new with read:user and repo:status permissions and add it as the GITHUB_TOKEN environment variable

$ yarn changeset version

The following error was encountered while generating changelog entries
We have escaped applying the changesets, and no files should have been affected
🦋  error Error: Please create a GitHub personal access token at https://github.com/settings/tokens/new with `read:user` and `repo:status` permissions and add it as the GITHUB_TOKEN environment variable

This is specified in the changeset docs, but it wasn't clear how to configure the permissions.

@arthurgousset
Copy link
Contributor Author

arthurgousset commented Jan 8, 2024

I'll ask @pputman-clabs if he can help elevate permissions of GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} to include read:user and repo:status.

@arthurgousset
Copy link
Contributor Author

Test on local machine

Changeset generated CHANGELOG as expected locally.

Created Github Personal Access Token from my personal account for the celo-org Github org, as suggested here:

Ran

$ GITHUB_TOKEN='<paste-token-here>' yarn changeset version

Successfully generated the following CHANGELOG.md on this test branch:

3.1.5

Patch Changes

3.1.4

Patch Changes

  • Adds bogus changeset to test the newly configured CHANGELOG.md

Source: bogus branch > CHANGELOG.md

@arthurgousset
Copy link
Contributor Author

So as long as the GITHUB_TOKEN on CI has at least read:user and repo:status permissions. This PR should work as expected @aaronmgdr.

Copy link
Contributor

@nicolasbrugneaux nicolasbrugneaux left a comment

Choose a reason for hiding this comment

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

Bit tedious to test this locally but from what I see in both comments and other packages using the @changesets/changelog-github, then it looks good to go!

@arthurgousset
Copy link
Contributor Author

Bit tedious to test this locally but from what I see in both comments and other packages using the @changesets/changelog-github, then it looks good to go!

+1, we can always revert this PR if something goes wrong in the next CHANGELOG generation.

@arthurgousset arthurgousset merged commit a538be7 into master Jan 10, 2024
14 checks passed
@arthurgousset arthurgousset deleted the 0xarthurxyz/customise-changelog branch January 10, 2024 11:32
@arthurgousset
Copy link
Contributor Author

arthurgousset commented Jan 10, 2024

Slack convo with @pputman-clabs to assert that CI has sufficient Github permissions. At the latest, we'll know whether it works or not in the next release.

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.

Configure changeset to thank PR contributors and write to CHANGELOG.md
4 participants