-
Notifications
You must be signed in to change notification settings - Fork 24
feat: use upstream release-please #334
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,25 @@ | ||
| { | ||
| "separate-pull-requests": {{{ del }}}, | ||
| "plugins": {{#if isMonoPublic }}["node-workspace"]{{ else }}{{{ del }}}{{/if}}, | ||
| "exclude-packages-from-root": true, | ||
| {{#if isMonoPublic }} | ||
| "plugins": [ | ||
| "node-workspace", | ||
| "node-workspace-format" | ||
| ], | ||
| {{/if}} | ||
| "exclude-packages-from-root": {{{ del }}}, | ||
| "group-pull-request-title-pattern": "chore: release ${version}", | ||
| "pull-request-title-pattern": "chore: release${component} ${version}", | ||
| "changelog-sections": {{{ json changelogTypes }}}, | ||
| "prerelease-type": "pre", | ||
| "pull-request-header": " ", | ||
| "pull-request-footer": " ", | ||
| "packages": { | ||
| "{{ pkgPath }}": { | ||
| {{#if isRoot}}"package-name": ""{{/if}} | ||
| {{#if isRoot}} | ||
| "package-name": ""{{#if workspacePaths}}, | ||
| "exclude-paths": {{{ json workspacePaths }}} | ||
| {{/if}} | ||
| {{/if}} | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| const localeCompare = require('@isaacs/string-locale-compare')('en') | ||
| const { ManifestPlugin } = require('release-please/build/src/plugin.js') | ||
| const { addPath } = require('release-please/build/src/plugins/workspace.js') | ||
| const { TagName } = require('release-please/build/src/util/tag-name.js') | ||
| const { ROOT_PROJECT_PATH } = require('release-please/build/src/manifest.js') | ||
| const { DEPS, link, wrapSpecs } = require('./util.js') | ||
|
|
||
| const WORKSPACE_MESSAGE = (name, version) => `${DEPS}(workspace): ${name}@${version}` | ||
| const WORKSPACE_SCOPE = /(?<scope>workspace): `?(?<name>\S+?)[@\s](?<version>\S+?)`?$/gm | ||
|
|
||
| module.exports = class extends ManifestPlugin { | ||
| static WORKSPACE_MESSAGE = WORKSPACE_MESSAGE | ||
|
|
||
| #releasesByPackage = new Map() | ||
| #pathsByComponent = new Map() | ||
|
|
||
| async preconfigure (strategiesByPath) { | ||
| // First build a list of all releases that will happen based on | ||
| // the conventional commits | ||
| for (const path in strategiesByPath) { | ||
| const component = await strategiesByPath[path].getComponent() | ||
| const packageName = await await strategiesByPath[path].getDefaultPackageName() | ||
| this.#pathsByComponent.set(component, path) | ||
| this.#releasesByPackage.set(packageName, { path, component }) | ||
| } | ||
|
|
||
| return strategiesByPath | ||
| } | ||
|
|
||
| run (candidates) { | ||
| this.#rewriteWorkspaceChangelogItems(candidates) | ||
| this.#sortReleases(candidates) | ||
| return candidates | ||
| } | ||
|
|
||
| // I don't like how release-please formats workspace changelog entries | ||
| // so this rewrites them to look like the rest of our changelog. This can't | ||
| // be part of the changelog plugin since they are written after that by the | ||
| // node-workspace plugin. A possible PR to release-please could add an option | ||
| // to customize these or run them through the changelog notes generator. | ||
| #rewriteWorkspaceChangelogItems (candidates) { | ||
| for (const candidate of candidates) { | ||
| for (const release of candidate.pullRequest.body.releaseData) { | ||
| // Update notes with a link to each workspaces release notes | ||
| // now that we have all of the releases in a single pull request | ||
| release.notes = | ||
| release.notes.replace(WORKSPACE_SCOPE, (...args) => { | ||
| const { scope, name, version } = args.pop() | ||
| const { path, component } = this.#releasesByPackage.get(name) | ||
| const { tagSeparator, includeVInTag } = this.repositoryConfig[path] | ||
| const { repository: { owner, repo } } = this.github | ||
| const tag = new TagName(version, component, tagSeparator, includeVInTag).toString() | ||
| const url = `https://github.com/${owner}/${repo}/releases/tag/${tag}` | ||
| return `${link(scope, url)}: ${wrapSpecs(`${name}@${version}`)}` | ||
| }) | ||
|
|
||
| // remove the other release please dependencies list which always starts with | ||
| // the following line and then each line is indented. so we search for the line | ||
| // and remove and indented lines until the next non indented line. | ||
| let foundRemoveStart = false | ||
| let foundRemoveEnd = false | ||
| release.notes = release.notes | ||
| .split('\n') | ||
| .filter((line) => { | ||
| if (line === '* The following workspace dependencies were updated') { | ||
| foundRemoveStart = true | ||
| } else if (foundRemoveStart && !foundRemoveEnd) { | ||
| // TODO: test when inserted dependencies is not the last thing in the changelog | ||
| /* istanbul ignore next */ | ||
| if (!line || !line.startsWith(' ')) { | ||
| foundRemoveEnd = true | ||
| } | ||
| } | ||
| // If we found the start, remove all lines until we've found the end | ||
| return foundRemoveStart ? foundRemoveEnd : true | ||
| }) | ||
| .join('\n') | ||
|
|
||
| // Find the associated changelog and update that too | ||
| const path = this.#pathsByComponent.get(release.component) | ||
| for (const update of candidate.pullRequest.updates) { | ||
| if (update.path === addPath(path, 'CHANGELOG.md')) { | ||
| update.updater.changelogEntry = release.notes | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Sort root release to the top of the pull request | ||
| // release please pre sorts based on graph order so | ||
| #sortReleases (candidates) { | ||
| for (const candidate of candidates) { | ||
| candidate.pullRequest.body.releaseData.sort((a, b) => { | ||
| const aPath = this.#pathsByComponent.get(a.component) | ||
| const bPath = this.#pathsByComponent.get(b.component) | ||
| if (aPath === ROOT_PROJECT_PATH) { | ||
| return -1 | ||
| } | ||
| if (bPath === ROOT_PROJECT_PATH) { | ||
| return 1 | ||
| } | ||
| return localeCompare(aPath, bPath) | ||
| }) | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.