Skip to content

Commit

Permalink
chore(publish-version): use release notes in .github/
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Dec 1, 2024
1 parent bb11779 commit 367edb4
Showing 1 changed file with 37 additions and 7 deletions.
44 changes: 37 additions & 7 deletions scripts/publish-version/src/publishVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,30 @@ export async function publishVersion(args: {
}
})

// Commit files
let releaseNotes: string | undefined

const committedFiles = [changelogFile]

if (!args.tag && !args.patch) {
const releaseNotesFile =
newMajorVersion === lastMajorVersion
? '.github/next-minor.md'
: '.github/next-major.md'

releaseNotes = await fs.readFile(releaseNotesFile, 'utf8')

// Reset the file to its original state.
await execa('git', [
'checkout',
'e5e8292f053337013d1faadddcde67bcec9255a2',
'--',
releaseNotesFile,
])

committedFiles.push(releaseNotesFile)
}

// Commit files
if (!args.tag) {
// Only commit the changed version in package.json if it's a
// stable version being published.
Expand Down Expand Up @@ -236,17 +258,25 @@ export async function publishVersion(args: {

const octokit = new Octokit({ auth: args.radashiBotToken })

if (args.push && (args.patch || args.tag)) {
if (args.push) {
if (args.patch || args.tag) {
releaseNotes = await generateChangelog({
minimal: true,
base: 'v' + stableVersion,
token: args.gitCliffToken,
})
}

if (!releaseNotes) {
throw new Error('No release notes found')
}

log('Creating a release on GitHub')
await octokit.rest.repos.createRelease({
owner: 'radashi-org',
repo: args.tag ? 'radashi-canary' : 'radashi',
tag_name: newTag,
body: await generateChangelog({
minimal: true,
base: 'v' + stableVersion,
token: args.gitCliffToken,
}),
body: releaseNotes,
})
}

Expand Down

0 comments on commit 367edb4

Please sign in to comment.