-
Notifications
You must be signed in to change notification settings - Fork 273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(lite/release): add changelog to gh release description #8265
base: master
Are you sure you want to change the base?
Conversation
const getChangelogForVersion = (version, changelogPath = './CHANGELOG.md') => { | ||
const changelog = readFileSync(changelogPath, 'utf8') | ||
|
||
const versionRegex = new RegExp(`## \\*\\*${version}\\*\\*.*?(?=\\n## \\*\\*|$)`, 's') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to escape .
characters in version
.
@@ -342,11 +352,14 @@ if (ghRelease) { | |||
stop() | |||
} | |||
} else { | |||
const releaseNotes = getChangelogForVersion(version) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should at least prompt something if releaseNotes
is null
because it's not expected and it might mean something is wrong with the version numbers.
@@ -4,6 +4,7 @@ import argv from 'minimist' | |||
import { tmpdir } from 'os' | |||
import { fileURLToPath, URL } from 'url' | |||
import { $, cd, chalk, fs, path, question, within } from 'zx' | |||
import { readFileSync } from 'fs' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use fs.readFile
from the zx
library.
d6682e2
to
03c16e5
Compare
if (!releaseNotes) { | ||
if (await no(`No changelog found for version ${version}. There might be a problem with the version number.`)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There needs to be a question like "Continue anyway?" at the end of the prompt and you only need one if
with the 2 conditions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I think I'd also like to re-organize this chunk of code into something that looks like this in terms of logic so that we don't prompt about a missing changelog if the release already exists anyway:
release = ghApiCall(...).find(...)
if (release !== undefined && no('release already exists, continue?')) {
stop()
}
if (release === undefined) {
releaseNotes = getChangelogForVersion(version)
if (releaseNotes === undefined && no('changelog not found, continue?')) {
stop()
}
release = ghApiCall(..., { ..., body: releaseNotes })
}
Does it make sense? We can also do that in another PR if you think it's drifting too much away from the purpose of this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a good idea, I will implement this
60bba38
to
a5b0322
Compare
)}). Skip and proceed with upload?` | ||
) | ||
) { | ||
if (release !== undefined && (await no('release already exists, continue?'))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can keep the longer prompts though, this was just for the example :)
if (release === undefined) { | ||
const releaseNotes = await getChangelogForVersion(version) | ||
|
||
if (releaseNotes === undefined && (await no('changelog not found, continue?'))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one too :) At least mentioning the version number for easier debug.
) | ||
releaseNotes === undefined && | ||
(await no( | ||
`Could not find changelog for version ${version}.(${chalk.yellow(release.html_url)}). Create release without changelog?` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
release
is undefined
here.
`Could not find changelog for version ${version}.(${chalk.yellow(release.html_url)}). Create release without changelog?` | |
`Could not find changelog for version ${version}. Create release without changelog?` |
Description
Add changeLog to GitHub release description
Checklist
Fixes #007
,See xoa-support#42
,See https://...
)Introduced by
CHANGELOG.unreleased.md
Review process
Notes: