-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Open or update a GitHub issue with informations about the errors that caused the release to fail - Update the `success` hook to close the issue when a release is successful
- Loading branch information
Showing
17 changed files
with
1,101 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = '<!-- semantic-release:github -->'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const {template} = require('lodash'); | ||
const parseGithubUrl = require('parse-github-url'); | ||
const debug = require('debug')('semantic-release:github'); | ||
const ISSUE_ID = require('./definitions/sr-issue-id'); | ||
const resolveConfig = require('./resolve-config'); | ||
const getClient = require('./get-client'); | ||
const findSRIssues = require('./find-sr-issues'); | ||
const getFailComment = require('./get-fail-comment'); | ||
|
||
module.exports = async (pluginConfig, {options: {branch, repositoryUrl}, errors, logger}) => { | ||
const {githubToken, githubUrl, githubApiPathPrefix, failComment, failTitle, labels, assignees} = resolveConfig( | ||
pluginConfig | ||
); | ||
const {name: repo, owner} = parseGithubUrl(repositoryUrl); | ||
const github = getClient(githubToken, githubUrl, githubApiPathPrefix); | ||
const body = failComment ? template(failComment)({branch, errors}) : getFailComment(branch, errors); | ||
const srIssue = (await findSRIssues(github, failTitle, owner, repo))[0]; | ||
|
||
if (srIssue) { | ||
logger.log('Found existing semantic-release issue #%d.', srIssue.number); | ||
const comment = {owner, repo, number: srIssue.number, body}; | ||
debug('create comment: %O', comment); | ||
const {data: {html_url: url}} = await github.issues.createComment(comment); | ||
logger.log('Added comment to issue #%d: %s.', srIssue.number, url); | ||
} else { | ||
const newIssue = {owner, repo, title: failTitle, body: `${body}\n\n${ISSUE_ID}`, labels, assignees}; | ||
debug('create issue: %O', newIssue); | ||
const {data: {html_url: url, number}} = await github.issues.create(newIssue); | ||
logger.log('Created issue #%d: %s.', number, url); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const ISSUE_ID = require('./definitions/sr-issue-id'); | ||
|
||
module.exports = async (github, title, owner, repo) => { | ||
const {data: {items: issues}} = await github.search.issues({ | ||
q: `title:${title}+repo:${owner}/${repo}+type:issue+state:open`, | ||
}); | ||
|
||
return issues.filter(issue => issue.body && issue.body.includes(ISSUE_ID)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const HOME_URL = 'https://github.com/semantic-release/semantic-release'; | ||
const FAQ_URL = `${HOME_URL}/blob/caribou/docs/support/FAQ.md`; | ||
const GET_HELP_URL = `${HOME_URL}#get-help`; | ||
const USAGE_DOC_URL = `${HOME_URL}/blob/caribou/docs/usage/README.md`; | ||
const NEW_ISSUE_URL = `${HOME_URL}/issues/new`; | ||
|
||
const formatError = error => `### ${error.message} | ||
${error.details || | ||
`Unfortunatly this error doesn't have any additionnal information.${ | ||
error.pluginName | ||
? ` Feel free to kindly ask the author of the \`${error.pluginName}\` plugin to add more helpful informations.` | ||
: '' | ||
}`}`; | ||
|
||
module.exports = ( | ||
branch, | ||
errors | ||
) => `## :rotating_light: The automated release from the \`${branch}\` branch failed. :rotating_light: | ||
I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features. | ||
You can find below the list of errors reported by **semantic-release**. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this 💪. | ||
Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it. | ||
Once all the errors are resolved, **semantic-release** will release your package the next time you push a commit the \`${branch}\` branch. You can also manually restart the failed CI job that runs **semantic-release**. | ||
If you are not sure how to resolve this, here is some links that can help you: | ||
- [Usage documentation](${USAGE_DOC_URL}) | ||
- [Frequently Asked Questions](${FAQ_URL}) | ||
- [Support channels](${GET_HELP_URL}) | ||
If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind **[semantic-release](${NEW_ISSUE_URL})**. | ||
--- | ||
${errors.map(formatError).join('\n\n---\n\n')} | ||
--- | ||
Good luck with your project ✨ | ||
Your **[semantic-release](${HOME_URL})** bot :package::rocket:`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,23 @@ | ||
const {castArray} = require('lodash'); | ||
const {isUndefined, castArray} = require('lodash'); | ||
|
||
module.exports = ({githubUrl, githubApiPathPrefix, assets, successComment}) => ({ | ||
module.exports = ({ | ||
githubUrl, | ||
githubApiPathPrefix, | ||
assets, | ||
successComment, | ||
failComment, | ||
failTitle, | ||
labels, | ||
assignees, | ||
}) => ({ | ||
githubToken: process.env.GH_TOKEN || process.env.GITHUB_TOKEN, | ||
githubUrl: githubUrl || process.env.GH_URL || process.env.GITHUB_URL, | ||
githubApiPathPrefix: githubApiPathPrefix || process.env.GH_PREFIX || process.env.GITHUB_PREFIX || '', | ||
assets: assets ? castArray(assets) : assets, | ||
successComment, | ||
failComment, | ||
failTitle: | ||
isUndefined(failTitle) || failTitle === false ? 'The automated release is failing :rotating_light:' : failTitle, | ||
labels: isUndefined(labels) ? ['semantic-release'] : labels === false ? [] : castArray(labels), | ||
assignees: assignees ? castArray(assignees) : assignees, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.