mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
ci: update changelog with github tags/handles of users
This commit is contained in:
parent
f1fe97fc8a
commit
60ab5deb0f
@ -1,3 +1,4 @@
|
|||||||
|
import { execSync } from 'node:child_process'
|
||||||
import { promises as fsp } from 'node:fs'
|
import { promises as fsp } from 'node:fs'
|
||||||
import { resolve } from 'pathe'
|
import { resolve } from 'pathe'
|
||||||
import { globby } from 'globby'
|
import { globby } from 'globby'
|
||||||
@ -112,3 +113,25 @@ export async function getLatestCommits () {
|
|||||||
|
|
||||||
return parseCommits(await getGitDiff(latestTag), config)
|
return parseCommits(await getGitDiff(latestTag), config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getContributors () {
|
||||||
|
const contributors = [] as Array<{ name: string, username: string }>
|
||||||
|
const emails = new Set<string>()
|
||||||
|
const latestTag = execSync('git describe --tags --abbrev=0').toString().trim()
|
||||||
|
const rawCommits = await getGitDiff(latestTag)
|
||||||
|
for (const commit of rawCommits) {
|
||||||
|
if (emails.has(commit.author.email) || commit.author.name === 'renovate[bot]') { continue }
|
||||||
|
const { author } = await $fetch<{ author: { login: string, email: string }}>(`https://api.github.com/repos/nuxt/nuxt/commits/${commit.shortHash}`, {
|
||||||
|
headers: {
|
||||||
|
'User-Agent': 'nuxt/nuxt',
|
||||||
|
Accept: 'application/vnd.github.v3+json',
|
||||||
|
Authorization: `token ${process.env.GITHUB_TOKEN}`
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (!contributors.some(c => c.username === author.login)) {
|
||||||
|
contributors.push({ name: commit.author.name, username: author.login })
|
||||||
|
}
|
||||||
|
emails.add(author.email)
|
||||||
|
}
|
||||||
|
return contributors
|
||||||
|
}
|
||||||
|
@ -3,7 +3,7 @@ import { $fetch } from 'ofetch'
|
|||||||
import { inc } from 'semver'
|
import { inc } from 'semver'
|
||||||
import { generateMarkDown, getCurrentGitBranch, loadChangelogConfig } from 'changelogen'
|
import { generateMarkDown, getCurrentGitBranch, loadChangelogConfig } from 'changelogen'
|
||||||
import { consola } from 'consola'
|
import { consola } from 'consola'
|
||||||
import { determineBumpType, getLatestCommits, loadWorkspace } from './_utils'
|
import { determineBumpType, getContributors, getLatestCommits, loadWorkspace } from './_utils'
|
||||||
|
|
||||||
async function main () {
|
async function main () {
|
||||||
const releaseBranch = await getCurrentGitBranch()
|
const releaseBranch = await getCurrentGitBranch()
|
||||||
@ -36,11 +36,17 @@ async function main () {
|
|||||||
|
|
||||||
// Get the current PR for this release, if it exists
|
// Get the current PR for this release, if it exists
|
||||||
const [currentPR] = await $fetch(`https://api.github.com/repos/nuxt/nuxt/pulls?head=nuxt:v${newVersion}`)
|
const [currentPR] = await $fetch(`https://api.github.com/repos/nuxt/nuxt/pulls?head=nuxt:v${newVersion}`)
|
||||||
|
const contributors = await getContributors()
|
||||||
|
|
||||||
const releaseNotes = [
|
const releaseNotes = [
|
||||||
currentPR?.body.replace(/## 👉 Changelog[\s\S]*$/, '') || `> ${newVersion} is the next ${bumpType} release.\n>\n> **Timetable**: to be announced.`,
|
currentPR?.body.replace(/## 👉 Changelog[\s\S]*$/, '') || `> ${newVersion} is the next ${bumpType} release.\n>\n> **Timetable**: to be announced.`,
|
||||||
'## 👉 Changelog',
|
'## 👉 Changelog',
|
||||||
changelog.replace(/^## v.*?\n/, '').replace(`...${releaseBranch}`, `...v${newVersion}`)
|
changelog
|
||||||
|
.replace(/^## v.*?\n/, '')
|
||||||
|
.replace(`...${releaseBranch}`, `...v${newVersion}`)
|
||||||
|
.replace(/### ❤️ Contributors[\s\S]*$/, ''),
|
||||||
|
`### ❤️ Contributors`,
|
||||||
|
contributors.map(c => `- ${c.name} (@${c.username})`).join('\n')
|
||||||
].join('\n')
|
].join('\n')
|
||||||
|
|
||||||
// Create a PR with release notes if none exists
|
// Create a PR with release notes if none exists
|
||||||
|
Loading…
Reference in New Issue
Block a user