Skip to content

Commit

Permalink
Merge pull request #16 from Updater/semantic-release-13
Browse files Browse the repository at this point in the history
Semantic release 13
  • Loading branch information
pmowrer authored Feb 11, 2018
2 parents 709e2e8 + 7b9f4e6 commit 829d0f5
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 138 deletions.
4 changes: 3 additions & 1 deletion bin/semantic-release-github-pr.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ const { getCurrentBranchName } = require('../src/git-utils');
// let us unless we pass `--no-ci`.
// https://github.com/semantic-release/semantic-release/issues/584
`--no-ci`,
// Set `dry-run` to keep `semantic-release` from publishing an actual release.
`--dry-run`,
`--branch=${branch}`,
`--analyze-commits=${plugins}`,
`--generate-notes=${plugins}`,
`--verify-conditions=@semantic-release/github,${plugins}`,
`--publish=${plugins}`,
]);

execa('semantic-release', args, { stdio: 'inherit' });
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"bin": "./bin/semantic-release-github-pr.js",
"license": "MIT",
"peerDependencies": {
"semantic-release": "^12.2.5"
"semantic-release": "^12.2.5 - 13"
},
"dependencies": {
"execa": "^0.8.0",
Expand All @@ -31,7 +31,7 @@
"jest": "^22.0.4",
"lint-staged": "^6.0.0",
"prettier": "^1.8.2",
"semantic-release": "^12.4.1"
"semantic-release": "^13.2.0"
},
"lint-staged": {
"*.js": ["yarn format", "git add"]
Expand Down
31 changes: 21 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ const decoratePlugins = compose(
);

// Use `verifyConditions` plugin as a hook to clean up stale changelog comments.
// We can't do this in `publish` since it only runs if there's a new release.
// We can't do this in `generateNotes` since it only runs if there's a new release.
const verifyConditions = async (pluginConfig, config) => {
const { pullRequests } = pluginConfig;
await pullRequests.forEach(deleteChangelog(pluginConfig, config));
};

// Use `analyzeCommits` plugin as a hook to post a "no release" PR comment if
// there isn't a new release. We can't do this in `publish` since it only runs
// there isn't a new release. We can't do this in `generateNotes` since it only runs
// if there's a new release.
const analyzeCommits = wrapPlugin(
NAMESPACE,
Expand Down Expand Up @@ -58,16 +58,27 @@ const analyzeCommits = wrapPlugin(
pluginDefinitions.analyzeCommits.default
);

const publish = async (pluginConfig, config) => {
const { pullRequests } = pluginConfig;
await pullRequests.forEach(
// Create "release" comment
createChangelog(pluginConfig, config)
);
};
const generateNotes = wrapPlugin(
NAMESPACE,
'generateNotes',
plugin => async (pluginConfig, config) => {
const { pullRequests } = pluginConfig;
const { nextRelease } = config;

nextRelease.notes = await plugin(pluginConfig, config);

await pullRequests.forEach(
// Create "release" comment
createChangelog(pluginConfig, { ...config, nextRelease })
);

return nextRelease.notes;
},
pluginDefinitions.generateNotes.default
);

module.exports = {
analyzeCommits: decoratePlugins(analyzeCommits),
publish: decoratePlugins(publish),
generateNotes: decoratePlugins(generateNotes),
verifyConditions: decoratePlugins(verifyConditions),
};
Loading

0 comments on commit 829d0f5

Please sign in to comment.