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

How to get release notes from CHANGELOG? #4724

Closed
simoneb opened this issue Oct 17, 2019 · 31 comments
Closed

How to get release notes from CHANGELOG? #4724

simoneb opened this issue Oct 17, 2019 · 31 comments
Assignees
Labels
core:changelogs Related to changelogs/release notes fetching manager:npm package.json files (npm/yarn/pnpm) priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others type:bug Bug fix of existing functionality

Comments

@simoneb
Copy link

simoneb commented Oct 17, 2019

Which Renovate are you using? CLI, App, or Pro

App

Which platform are you using? GitHub, GitLab, Bitbucket Azure DevOps

GitHub

What is your question?

We're publishing some packages which are used by our applications and as part of an improvement of the package publishing process we're now generating and including a CHANGELOG file in the package.
We thought that this would be enough to get the Release Notes section to show in the PRs created by Renovate but it turns out it's not the case. Checking other packages I realized that the release notes are probably coming from GitHub's releases page instead.

Is there a reason why the CHANGELOG file isn't used instead? I feel it would make more sense for release notes to come from a file within the package rather than the platform where the source code of the package is hosted.

@rarkins
Copy link
Collaborator

rarkins commented Oct 17, 2019

We do support changelog files, but there's a number of things that could possibly be going wrong. Please answer the following:

What type of dependency is it? e.g. npm?
Where is it hosted? npmjs.com or self-hosted?
Is the source repository on github.com?
Does the package correctly reference the source repository?
What is the exact filename?
What formatting/convention are you using inside the changelog file?

@simoneb
Copy link
Author

simoneb commented Oct 17, 2019

We do support changelog files, but there's a number of things that could possibly be going wrong. Please answer the following:

What type of dependency is it? e.g. npm?

npm

Where is it hosted? npmjs.com or self-hosted?

self-hosted. we configured everything needed to pull from our private registry already in the renovate.json file

Is the source repository on github.com?

yes

Does the package correctly reference the source repository?

yes UPDATE: no, it doesn't

What is the exact filename?

CHANGELOG.md

What formatting/convention are you using inside the changelog file?

conventional commits

@simoneb
Copy link
Author

simoneb commented Oct 17, 2019

@rarkins see the update above, the package.json file doesn't reference the repo (it's a monorepo btw)

@rarkins
Copy link
Collaborator

rarkins commented Oct 17, 2019

So in that case Renovate has no sourceUrl to know where to look. Are you using a shared CHANGELOG.mde in the root of the monorepo or one changelog per package?

@simoneb
Copy link
Author

simoneb commented Oct 17, 2019

A CHANGELOG per package. What should I put in that package's package.json file to make it pick up the release notes from the CHANGELOG.md file?

@rarkins
Copy link
Collaborator

rarkins commented Oct 17, 2019

Follow the npm docs here: https://docs.npmjs.com/files/package.json#repository

Specifically:

image

@simoneb
Copy link
Author

simoneb commented Oct 17, 2019

thanks @rarkins, will try. so, with all that in place, Renovate should be able to generate PR release notes using the CHANGELOG.md file in the repository, right?

@rarkins
Copy link
Collaborator

rarkins commented Oct 17, 2019

In theory yes, although nested changelog retrieval is definitely not something I've extensively tested. At the very least we're ready for testing and reproducing any bugs

@simoneb
Copy link
Author

simoneb commented Oct 20, 2019

Hi @rarkins. We tried it out and now we get a Release Notes section in the PRs for the package, so it's a step forward! Unfortunately though, we don't get the list of changes. Here's what it looks like:

image

The CHANGELOG.md file contains changes in the form generated by conventional changelog. Here's the top of that file (sensitive data redacted):

# Changelog

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [0.10.2](https://github.com/{...}) (2019-10-19)


### Features

* some feature ([#123](https://github.com/{...})) ([123](https://github.com/{123}))


### Bug Fixes

* some bug fix ([#456](https://github.com/{...})) ([456](https://github.com/{...}))

@rarkins
Copy link
Collaborator

rarkins commented Oct 20, 2019

Can you give an example of what you’re expecting instead?

@simoneb
Copy link
Author

simoneb commented Oct 20, 2019

I would expect the list of changes as described in the changelog

@simoneb

This comment has been minimized.

@rarkins
Copy link
Collaborator

rarkins commented Oct 21, 2019

Sorry, I misunderstood the part you had pasted in previously. I thought the changelog markdown content you added was already in the PR, and you were expecting more (a list of commits, etc). I deleted my comment and minimized yours.

What you're seeing implies that Renovate is not actually detecting the Changelog.md in the source repository. It looks like it's detecting the tags in the source repo and linking accordingly (please confirm that the 0.10.2 link in your screenshot links to the correct location).

@simoneb
Copy link
Author

simoneb commented Oct 21, 2019

It's alright, thanks for your support. The link in the screenshot links to {repo}/compare/v0.10.1...v0.10.2, not sure if that's the intended behavior. To summarize the current situation, it's all as described here except that I've now added this section in the package.json file.

Without that, no Release Notes section was appearing in the Renovate PR.
With that, now there is a Release Notes section as shown in the screenshot but no summary of changes (features, bugs, ...)

@simoneb
Copy link
Author

simoneb commented Oct 22, 2019

Hi @rarkins, I'm posting an update because the appearance of the release notes unfortunately seems to have been triggered by us publishing a Release to GitHub, and indeed the Changelog file doesn't seem to be picked up. We were trying several things and at some point we published a release. For the next version bump we didn't publish the release and the release notes in the Renovate PR have disappeared again, meaning that indeed it's not picking up the Changelog. Other ideas?

@rarkins
Copy link
Collaborator

rarkins commented Oct 22, 2019

We might only be able to solve this after reproducing it publicly so that it can be debugged from the CLI. Before then though, it might be easier for you to reproduce it internally and share the logs. Can you do this?

  1. Create a new repository
  2. Add a package.json depending on the same package and out of date version
  3. Add the repository to Renovate and onboard it with same config
  4. Wait for the PR to come (presumably missing the changelog)
  5. We check out the debug log to see if there's any hints on what's going wrong when it does the release notes hunting

@simoneb
Copy link
Author

simoneb commented Oct 23, 2019

Hi @rarkins, thanks for your support so far. Here's a repro on a public repository.

  • I have created a monorepo using lerna with a nested package which I'm publishing to npm here. I have configured its package.json file as described here
  • I have created a target app, which uses the nested package from the monorepo and enabled Renovate on it here
  • I am using lerna to automatically generate changelogs. Note that lerna generates both a changelog in the root of the monorepo and one in the specific package. I'm looking for a way to Renovate to pick up the changelog of the nested package, not that of the root of the repo
  • Here's the result of publishing a new version of the package to npm and Renovate creating a PR for it. You can see that the PR contains release notes obtained from the changelog at the root of the monorepo, rather than that of the nested package. The latter is what I need as the changes of the whole monorepo are not relevant for the specific package bump. You can see it's picking up the changelog at the root of the monorepo by the "notes" in the PR, which say

Note: Version bump only for package root

whereas it would say

Note: Version bump only for package renovate-monorepo-package

if Renovate was picking them up from the nested package's changelog file.

I hope this helps troubleshoot the issue

@rarkins rarkins transferred this issue from renovatebot/config-help Oct 25, 2019
@rarkins
Copy link
Collaborator

rarkins commented Oct 25, 2019

Thanks for reproducing it. I have now moved it into the main repo as it seems we need code changes and not config changes.

I think the logic error occurs in here:

let apiPrefix = githubApiBaseUrl.replace(/\/?$/, '/');
apiPrefix += `repos/${repository}/contents/`;
const filesRes = await ghGot(apiPrefix);
const files = filesRes.body
.map(f => f.name)
.filter(f => changelogFilenameRegex.test(f));
if (!files.length) {
logger.trace('no changelog file found');
return null;
}
[changelogFile] = files;
/* istanbul ignore if */
if (files.length > 1) {
logger.info(
`Multiple candidates for changelog file, using ${changelogFile}`
);
}

It needs to be adapted to consider the sourceDirectory first, if present.

@rarkins rarkins added manager:npm package.json files (npm/yarn/pnpm) type:bug Bug fix of existing functionality priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others ready labels Oct 25, 2019
@simoneb
Copy link
Author

simoneb commented Oct 26, 2019

Thanks for looking into this @rarkins.

From what I see in the code nested changelog files don't seem to be supported. I've set up renovate locally to see if I could contribute an improvement, but it looks like this would be an entirely new feature, and I'm not sure how to go about it. The function you linked to above probably needs to be modified quite a bit to account for nested packages, so it would have to have knowledge of monorepos and the specific package manager.

I am easily missing something as I'm not familiar with the Renovate codebase, but a straightforward implementation would require to look into the specific package we're trying to bump, read its package.json file, figure out what is the path of the package in order to pick up the right CHANGELOG file. But surely there is more complexity than this to make sure that we're staying compliant with tech stacks other than Node.js.

@rarkins
Copy link
Collaborator

rarkins commented Oct 31, 2019

@simoneb I was hoping that there would be a variable sourceDirectory passed through to the changelog step that can then be used to directly look for the changelog. I'll try to debug your example to see if that's true

@rodoabad
Copy link

@simoneb are you using git, git+https or https? in your repository declaration in package.json?

@simoneb
Copy link
Author

simoneb commented Jul 26, 2020

@simoneb are you using git, git+https or https? in your repository declaration in package.json?

A mix of the various options across different repositories. Is there one option that is expected to work?

I could update the repro to include that and see if it works.

@sppatel
Copy link

sppatel commented Nov 3, 2020

If the change log is only in the published npm package will renovate discover this and use it for the release notes, or does it reach out to the source repository and extract it from there? In my scenario, the CHANGELOG is not sourced, and only exists in each package distribution on the registry.

@rarkins
Copy link
Collaborator

rarkins commented Nov 3, 2020

Only the source repo. We don't download/extract artifacts from registries

@cawa-93
Copy link

cawa-93 commented Mar 30, 2021

Could you take a look at this PR:
cawa-93/vite-electron-builder#192

I do not understand why the release notes are not loaded. I recently added repository.directory to all packages/**/package.json in this monorepo, but it didn't help (

@BeeeQueue
Copy link

Would it be possible to extract changelogs from the package files when updating? Packages that have them often include them when publishing

image

@jasikpark
Copy link

Could documentation be added about where renovatebot looks for changelogs in monorepos? We're trying to get detection working with https://github.com/snowpackjs/astro/ and I was hoping just specifying the source URL would fix things.

@rarkins
Copy link
Collaborator

rarkins commented Jun 16, 2021

Renovate should follow the convention described here for monorepos: https://docs.npmjs.com/cli/v7/configuring-npm/package-json#repository

e.g.

{
  "repository": {
    "type": "git",
    "url": "https://github.com/facebook/react.git",
    "directory": "packages/react-dom"
  }
}

If it's still not working, please create a simply reproduction repo upgrading one of your monorepo packages (and failing to show the release notes) and we can take a look and fix things if necessary.

@jasikpark
Copy link

Sure thing! I did that, but it's still not working: https://github.com/jasikpark/my-astro-project/pull/7

  "repository": {
    "type": "git",
    "url": "https://github.com/snowpackjs/astro.git",
    "directory": "packages/astro"
  },

https://github.com/snowpackjs/astro/blob/e7b2a6d8dd163dbddf8d2bdf380e48b336c56a75/packages/astro/package.json#L8-L12

@rarkins
Copy link
Collaborator

rarkins commented Jun 17, 2021

FYI I have reproduced this problem using your project and have a fix in progress

@HonkingGoose HonkingGoose added the core:changelogs Related to changelogs/release notes fetching label Nov 13, 2021
@viceice
Copy link
Member

viceice commented Feb 10, 2022

Isn't this fixed ?

@rarkins rarkins closed this as completed Feb 11, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
core:changelogs Related to changelogs/release notes fetching manager:npm package.json files (npm/yarn/pnpm) priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others type:bug Bug fix of existing functionality
Projects
None yet
Development

No branches or pull requests

9 participants