Skip to content

Commit ccb50c6

Browse files
Automatically add type: release and skip-changelog to release PRs (#59)
Also adds possibility to attach labels to the release PR : By default it attaches `skip-changelog` and `type: release` to the newly created release PR. It happened in some occasions that the release PR leaked into the changelog of the next release, requiring the release lead to manually remove it.
2 parents fcba46a + 5987c80 commit ccb50c6

File tree

5 files changed

+31
-6
lines changed

5 files changed

+31
-6
lines changed

dist/index.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports =
66
/***/ ((module) => {
77

88
"use strict";
9-
module.exports = JSON.parse("{\"labelTypePrefix\":\"type: \",\"labelTypeMap\":{\"bug\":\"Bug Fixes\",\"regression\":\"Bug Fixes\",\"feature\":\"Features\",\"enhancement\":\"Enhancements\",\"new api\":\"New APIs\",\"experimental\":\"Experiments\",\"task\":\"Various\"},\"groupTitleOrder\":[\"Features\",\"Enhancements\",\"New APIs\",\"Bug Fixes\",\"Performance\",\"Experiments\",\"Documentation\",\"Code Quality\",\"undefined\",\"Various\"],\"rewordTerms\":{\"e2e\":\"end-to-end\",\"url\":\"URL\",\"config\":\"configuration\",\"docs\":\"documentation\"},\"needsDevNoteLabel\":\"status:needs-dev-note\",\"labelsToOmit\":[\"skip-changelog\"]}");
9+
module.exports = JSON.parse("{\"labelTypePrefix\":\"type: \",\"labelTypeMap\":{\"bug\":\"Bug Fixes\",\"regression\":\"Bug Fixes\",\"feature\":\"Features\",\"enhancement\":\"Enhancements\",\"new api\":\"New APIs\",\"experimental\":\"Experiments\",\"task\":\"Various\"},\"groupTitleOrder\":[\"Features\",\"Enhancements\",\"New APIs\",\"Bug Fixes\",\"Performance\",\"Experiments\",\"Documentation\",\"Code Quality\",\"undefined\",\"Various\"],\"rewordTerms\":{\"e2e\":\"end-to-end\",\"url\":\"URL\",\"config\":\"configuration\",\"docs\":\"documentation\"},\"needsDevNoteLabel\":\"status:needs-dev-note\",\"labelsToOmit\":[\"skip-changelog\"],\"releasePRLabels\":[\"skip-changelog\",\"type: release\"]}");
1010

1111
/***/ }),
1212

@@ -460,9 +460,11 @@ const insertNewChangelogEntry = ( contents, changelog, releaseVersion ) => {
460460
const regex = /== Changelog ==\n/;
461461
return contents.replace(
462462
regex,
463-
`== Changelog ==\n\n= ${ releaseVersion } - ${ new Date().toISOString().split('T')[0] } =\n\n${ changelog }`
463+
`== Changelog ==\n\n= ${ releaseVersion } - ${
464+
new Date().toISOString().split( 'T' )[ 0 ]
465+
} =\n\n${ changelog }`
464466
);
465-
}
467+
};
466468

467469
/**
468470
* Inserts the new changelog entry into the readme file contents
@@ -742,6 +744,12 @@ const branchHandler = async ( context, octokit, config ) => {
742744
compile( initialChecklistTemplate )( templateData )
743745
);
744746

747+
await octokit.issues.addLabels( {
748+
...context.repo,
749+
issue_number: prCreated.data.number,
750+
labels: config.releasePRLabels,
751+
} );
752+
745753
await octokit.issues.createComment( {
746754
...context.repo,
747755
issue_number: prCreated.data.number,

lib/automations/release/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ This is a label your project uses to indicate pull requests that require some ad
118118

119119
You can add any labels here that the changelog generator should use as a signal to omit the pull request from being included in the generated changelog.
120120

121+
**`releasePRLabels`**
122+
123+
You can add any labels here which will be attached to the new PR automatically created for each release. It defaults to adding `type: release` and `skip-changelog`.
124+
121125
## API
122126

123127
### Inputs
@@ -127,4 +131,4 @@ You can add any labels here that the changelog generator should use as a signal
127131

128132
### Outputs
129133

130-
_None._
134+
_None._

lib/automations/release/branch-create-handler.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ const insertNewChangelogEntry = ( contents, changelog, releaseVersion ) => {
4141
const regex = /== Changelog ==\n/;
4242
return contents.replace(
4343
regex,
44-
`== Changelog ==\n\n= ${ releaseVersion } - ${ new Date().toISOString().split('T')[0] } =\n\n${ changelog }`
44+
`== Changelog ==\n\n= ${ releaseVersion } - ${
45+
new Date().toISOString().split( 'T' )[ 0 ]
46+
} =\n\n${ changelog }`
4547
);
46-
}
48+
};
4749

4850
/**
4951
* Inserts the new changelog entry into the readme file contents
@@ -323,6 +325,12 @@ const branchHandler = async ( context, octokit, config ) => {
323325
compile( initialChecklistTemplate )( templateData )
324326
);
325327

328+
await octokit.issues.addLabels( {
329+
...context.repo,
330+
issue_number: prCreated.data.number,
331+
labels: config.releasePRLabels,
332+
} );
333+
326334
await octokit.issues.createComment( {
327335
...context.repo,
328336
issue_number: prCreated.data.number,

lib/automations/release/config/default.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,9 @@
3030
"needsDevNoteLabel": "status:needs-dev-note",
3131
"labelsToOmit": [
3232
"skip-changelog"
33+
],
34+
"releasePRLabels": [
35+
"skip-changelog",
36+
"type: release"
3337
]
3438
}

lib/typedefs.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
* @property {Array<string>} labelsToOmit When any label in this array is attached to
8282
* an issue/pull, then the entry should be
8383
* ignored in the changelog.
84+
* @property {Array<string>} releasePRLabels Labels to add to the release PR.
8485
*/
8586

8687
module.exports = {};

0 commit comments

Comments
 (0)