From 5c9bd237e34c38ae03a4defd5776aba56deec131 Mon Sep 17 00:00:00 2001 From: Joey Perrott Date: Fri, 30 Apr 2021 11:13:25 -0700 Subject: [PATCH] build: update release configuration to use new release notes system (#41905) Update the ng-dev config for release to use the new release notes system for generating release notes. PR Close #41905 --- .ng-dev/release.ts | 6 +-- gulpfile.js | 1 - tools/gulp-tasks/changelog.js | 73 ----------------------------------- 3 files changed, 2 insertions(+), 78 deletions(-) delete mode 100644 tools/gulp-tasks/changelog.js diff --git a/.ng-dev/release.ts b/.ng-dev/release.ts index 912b281d6a..b779529074 100644 --- a/.ng-dev/release.ts +++ b/.ng-dev/release.ts @@ -1,5 +1,4 @@ import {join} from 'path'; -import {exec} from 'shelljs'; import {ReleaseConfig} from '../dev-infra/release/config'; /** Configuration for the `ng-dev release` command. */ @@ -29,9 +28,8 @@ export const release: ReleaseConfig = { const {buildTargetPackages} = require(join(__dirname, '../scripts/build/package-builder')); return buildTargetPackages('dist/release-output', false, 'Release', true); }, - // TODO: This can be removed once there is an org-wide tool for changelog generation. - generateReleaseNotesForHead: async () => { - exec('yarn -s gulp changelog', {cwd: join(__dirname, '../')}); + releaseNotes: { + hiddenScopes: ['aio', 'dev-infra', 'docs-infra', 'zone.js'], }, releasePrLabels: ['comp: build & ci', 'action: merge', 'PullApprove: disable'], }; diff --git a/gulpfile.js b/gulpfile.js index 8c22aeb9f7..e4779fe862 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -19,7 +19,6 @@ function loadTask(fileName, taskName) { gulp.task('source-map-test', loadTask('source-map-test')); -gulp.task('changelog', loadTask('changelog')); gulp.task('changelog:zonejs', loadTask('changelog-zonejs')); gulp.task('cldr:extract', loadTask('cldr', 'extract')); gulp.task('cldr:download', loadTask('cldr', 'download')); diff --git a/tools/gulp-tasks/changelog.js b/tools/gulp-tasks/changelog.js deleted file mode 100644 index 0caaf1c0d5..0000000000 --- a/tools/gulp-tasks/changelog.js +++ /dev/null @@ -1,73 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -const {readFileSync} = require('fs'); -const {bold, yellow} = require('chalk'); - -module.exports = (gulp) => () => { - const conventionalChangelog = require('gulp-conventional-changelog'); - const ignoredScopes = [ - 'aio', - 'dev-infra', - 'docs-infra', - 'zone.js', - ]; - - return gulp.src('CHANGELOG.md') - .pipe(conventionalChangelog( - /* core options */ {preset: 'angular'}, - /* context options */ {}, - /* raw-commit options */ { - // Ignore commits that start with `()` for any of the ignored scopes. - extendedRegexp: true, - grep: `^[^(]+\\((${ignoredScopes.join('|')})\\)`, - invertGrep: true, - }, - /* commit parser options */ null, - /* writer options*/ createDedupeWriterOptions())) - .pipe(gulp.dest('./')); -}; - -/** - * Creates changelog writer options which ensure that commits are not showing up multiple times. - * Commits can show up multiple times if a changelog has been generated on a publish branch - * and has been cherry-picked into "master". In that case, the changelog will already contain - * commits from master which might be added to the changelog again. This is because usually - * patch and minor releases are tagged from the publish branches and therefore - * conventional-changelog tries to build the changelog from last minor version to HEAD when a - * new minor version is being published from the "master" branch. We naively match commit - * headers as otherwise we would need to query Git and diff commits between a given patch branch. - * The commit header is reliable enough as it contains a direct reference to the source PR. - */ -function createDedupeWriterOptions() { - const existingChangelogContent = readFileSync('CHANGELOG.md', 'utf8'); - - return { - // Specify a writer option that can be used to modify the content of a new changelog section. - // See: conventional-changelog/tree/master/packages/conventional-changelog-writer - finalizeContext: (context) => { - context.commitGroups = context.commitGroups.filter((group) => { - group.commits = group.commits.filter((commit) => { - // NOTE: We cannot compare the SHAs because the commits will have a different SHA - // if they are being cherry-picked into a different branch. - if (existingChangelogContent.includes(commit.subject)) { - console.info(yellow(` ↺ Skipping duplicate: "${bold(commit.header)}"`)); - return false; - } - return true; - }); - - // Filter out commit groups which don't have any commits. Commit groups will become - // empty if we filter out all duplicated commits. - return group.commits.length !== 0; - }); - - return context; - } - }; -}