Skip to content

Commit

Permalink
fix: update plugin wrappers for 15.11+ compat
Browse files Browse the repository at this point in the history
BREAKING CHANGE: This plugin now only supports `semantic-release` 15.11 and above.
  • Loading branch information
pmowrer committed Feb 4, 2020
1 parent 27dd61d commit 0433891
Show file tree
Hide file tree
Showing 6 changed files with 1,068 additions and 925 deletions.
3 changes: 3 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./src/index.js"
}
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- 8
- 10
notifications:
email: false
before_install:
Expand Down
33 changes: 1 addition & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# semantic-release-monorepo

[![Build Status](https://travis-ci.org/Updater/semantic-release-monorepo.svg?branch=master)](https://travis-ci.org/Updater/semantic-release-monorepo) [![npm](https://img.shields.io/npm/v/semantic-release-monorepo.svg)](https://www.npmjs.com/package/semantic-release-monorepo) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![Build Status](https://travis-ci.org/pmowrer/semantic-release-monorepo.svg?branch=master)](https://travis-ci.org/pmowrer/semantic-release-monorepo) [![npm](https://img.shields.io/npm/v/semantic-release-monorepo.svg)](https://www.npmjs.com/package/semantic-release-monorepo) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)

Apply [`semantic-release`'s](https://github.com/semantic-release/semantic-release) automatic publishing to a monorepo.

Expand Down Expand Up @@ -46,37 +46,6 @@ Note that this requires installing `semantic-release` and `semantic-release-mono

Alternatively, thanks to how [`npx's package resolution works`](https://github.com/zkat/npx#description), if the repository root is in `$PATH` (typically true on CI), `semantic-release` and `semantic-release-monorepo` can be installed once in the repo root instead of in each individual package, likely saving both time and disk space.

## Configuration

The set of plugins in this package wrap other `semantic-release` plugins to modify their behavior. By default, the same plugin configuration as `semantic-release` is used, but any plugin configuration should be compatible.

### Release config

Plugins can be configured in the [release config](https://github.com/semantic-release/semantic-release/blob/caribou/docs/usage/configuration.md#configuration), with one important caveat:

Due to limitations in how plugins may be composed ([discussion](https://github.com/semantic-release/semantic-release/issues/550)), `semantic-release-monorepo` must unfortunately "hard-code" the set of plugins it wraps: `analyze-commits` and `generateNotes`.

Users may still want to define a custom versions of the plugin set, or want to pass options to the default versions. To work around this problem, set the desired plugin configuration under the `monorepo` property instead.

#### Example of use with non-default set of plugins

`package.json`

```json
{
"release": {
"monorepo": {
"analyzeCommits": {
"format": "atom"
},
"generateNotes": "myNotesGenerator"
},
"prepare": ["@semantic-release/npm", "@semantic-release/git"],
"verifyConditions": ["@semantic-release/git"]
}
}
```

### Performance
Naturally, the more packages in a monorepo, the longer it takes `semantic-release` to run against all of them. If total runtime becomes a problem, consider the following optimization:

Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"license": "MIT",
"peerDependencies": {
"semantic-release": "13.4.1 - 15.x.x"
"semantic-release": ">=15.11.x"
},
"dependencies": {
"debug": "^3.1.0",
Expand All @@ -22,15 +22,15 @@
"pkg-up": "^2.0.0",
"ramda": "^0.25.0",
"read-pkg": "^3.0.0",
"semantic-release-plugin-decorators": "^1.2.1"
"semantic-release-plugin-decorators": "^2.1.0"
},
"devDependencies": {
"husky": "^4.2.1",
"jest": "^25.1.0",
"lint-staged": "^10.0.7",
"prettier": "^1.19.1",
"semantic-release": "^15.0.0",
"semantic-release-github-pr": "^5.0.5"
"semantic-release": "^17.0.2",
"semantic-release-github-pr": "^6.0.0"
},
"husky": {
"hooks": {
Expand Down
20 changes: 5 additions & 15 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,27 @@
const readPkg = require('read-pkg');
const { compose } = require('ramda');
const pluginDefinitions = require('semantic-release/lib/definitions/plugins');
const withOnlyPackageCommits = require('./only-package-commits');
const versionToGitTag = require('./version-to-git-tag');
const logPluginVersion = require('./log-plugin-version');
const {
wrapPlugin,
wrapMultiPlugin,
} = require('semantic-release-plugin-decorators');
const { wrapStep } = require('semantic-release-plugin-decorators');

const {
mapNextReleaseVersion,
withOptionsTransforms,
} = require('./options-transforms');

const NAMESPACE = 'monorepo';

const analyzeCommits = wrapPlugin(
NAMESPACE,
const analyzeCommits = wrapStep(
'analyzeCommits',
compose(logPluginVersion('analyzeCommits'), withOnlyPackageCommits),
pluginDefinitions.analyzeCommits.default
compose(logPluginVersion('analyzeCommits'), withOnlyPackageCommits)
);

const generateNotes = wrapMultiPlugin(
NAMESPACE,
const generateNotes = wrapStep(
'generateNotes',
compose(
logPluginVersion('generateNotes'),
withOnlyPackageCommits,
withOptionsTransforms([mapNextReleaseVersion(versionToGitTag)])
),
pluginDefinitions.generateNotes.default
)
);

module.exports = {
Expand Down
Loading

0 comments on commit 0433891

Please sign in to comment.