Skip to content

Commit e45b7c7

Browse files
author
Timo Notheisen
committed
feat: also release commits of PRs with label "dependencies"
1 parent 9afe5e5 commit e45b7c7

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Reusable GitHub Actions for js-soft repositories.
44

55
## release-dependency-updates
66

7-
Checks whether all commits on a branch since the latest GitHub release were authored by Renovate or Dependabot. If no latest GitHub release exists, it checks all commits on the branch instead. If all checked commits are dependency-bot commits, it creates a GitHub release with generated release notes.
7+
Checks whether all commits on a branch since the latest GitHub release were authored by Renovate or Dependabot, or are associated with pull requests labeled `dependencies`, `test`, `chore`, `refactoring`, or `ci`. If no latest GitHub release exists, it checks all commits on the branch instead. If all checked commits are releasable commits, it creates a GitHub release with generated release notes.
88

99
```yaml
1010
jobs:

release-dependency-updates/src/index.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const patchVersionPattern = /^(v?)(\d+)\.(\d+)\.(\d+)$/
1212

1313
const botAuthorLogins = new Set(["renovate[bot]", "dependabot[bot]"])
1414
const botAuthorNames = new Set(["renovate bot", "renovate[bot]", "dependabot[bot]", "dependabot"])
15-
const ignoredPullRequestLabels = new Set(["test", "chore", "refactoring", "ci"])
15+
const releasablePullRequestLabels = new Set(["test", "chore", "refactoring", "ci", "dependencies"])
1616
const botEmailFragments = [
1717
"renovate[bot]@users.noreply.github.com",
1818
"bot@renovateapp.com",
@@ -43,16 +43,16 @@ async function run() {
4343
}
4444

4545
const { commitCount, commits, nextTag, revisionDescription } = releasePreparation
46-
const nonDependencyBotCommits = await getNonDependencyBotCommits(octokit, owner, repo, commits)
47-
if (nonDependencyBotCommits.length > 0) {
48-
const commitList = nonDependencyBotCommits
46+
const nonReleasableCommits = await getNonReleasableCommits(octokit, owner, repo, commits)
47+
if (nonReleasableCommits.length > 0) {
48+
const commitList = nonReleasableCommits
4949
.slice(0, 10)
5050
.map((commit) => `- ${commit.sha.slice(0, 7)} ${commit.commit.message.split("\n")[0]}`)
5151
.join("\n")
5252

5353
core.notice(
5454
[
55-
`Found ${nonDependencyBotCommits.length} commit(s) in ${revisionDescription} that were not authored by Renovate or Dependabot.`,
55+
`Found ${nonReleasableCommits.length} commit(s) in ${revisionDescription} that were not authored by Renovate or Dependabot and do not have a releasable pull request label.`,
5656
commitList
5757
].join("\n")
5858
)
@@ -65,7 +65,7 @@ async function run() {
6565
}
6666

6767
core.debug(`Checked ${revisionDescription}: ${commitCount} commits.`)
68-
core.notice(`Creating ${nextTag} from ${commitCount} dependency-bot commit(s).`)
68+
core.notice(`Creating ${nextTag} from ${commitCount} releasable commit(s).`)
6969
await octokit.rest.repos.createRelease({
7070
owner,
7171
repo,
@@ -215,18 +215,18 @@ async function listCommits(octokit: Octokit, owner: string, repo: string, branch
215215
})
216216
}
217217

218-
async function getNonDependencyBotCommits(octokit: Octokit, owner: string, repo: string, commits: ReleaseCommit[]) {
219-
const nonDependencyBotCommits = []
218+
async function getNonReleasableCommits(octokit: Octokit, owner: string, repo: string, commits: ReleaseCommit[]) {
219+
const nonReleasableCommits = []
220220

221221
for (const commit of commits) {
222-
if (isDependencyBotCommit(commit) || (await isIgnoredPullRequestCommit(octokit, owner, repo, commit))) {
222+
if (isDependencyBotCommit(commit) || (await hasReleasablePullRequestLabel(octokit, owner, repo, commit))) {
223223
continue
224224
}
225225

226-
nonDependencyBotCommits.push(commit)
226+
nonReleasableCommits.push(commit)
227227
}
228228

229-
return nonDependencyBotCommits
229+
return nonReleasableCommits
230230
}
231231

232232
function isDependencyBotCommit(commit: ReleaseCommit) {
@@ -244,15 +244,15 @@ function isDependencyBotCommit(commit: ReleaseCommit) {
244244
return Boolean(authorEmail && botEmailFragments.some((fragment) => authorEmail.includes(fragment)))
245245
}
246246

247-
async function isIgnoredPullRequestCommit(octokit: Octokit, owner: string, repo: string, commit: ReleaseCommit) {
247+
async function hasReleasablePullRequestLabel(octokit: Octokit, owner: string, repo: string, commit: ReleaseCommit) {
248248
const { data: pullRequests } = await octokit.rest.repos.listPullRequestsAssociatedWithCommit({
249249
owner,
250250
repo,
251251
["commit_sha"]: commit.sha
252252
})
253253

254254
return pullRequests.some((pullRequest) =>
255-
pullRequest.labels.some((label) => ignoredPullRequestLabels.has(label.name.toLowerCase()))
255+
pullRequest.labels.some((label) => releasablePullRequestLabels.has(label.name.toLowerCase()))
256256
)
257257
}
258258

0 commit comments

Comments
 (0)