This repository has been archived by the owner on Feb 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: create a semantic-release plugin to release multiple packages
- Loading branch information
1 parent
c0b3b7b
commit e7e6512
Showing
5 changed files
with
50 additions
and
18 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
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,29 @@ | ||
const dirname = require('path').dirname; | ||
const shell = require('shelljs'); | ||
|
||
async function prepare({ packages }, context) { | ||
const PLACEHOLDER_VERSION = '0.0.0-development'; | ||
const { nextRelease: { version }, logger } = context; | ||
|
||
shell | ||
.ls(`${packages}/*/package.json`) | ||
.forEach(file => { | ||
shell.sed('-i', PLACEHOLDER_VERSION, version, file); | ||
shell.exec(`npm version ${version} --no-git-tag-version`, { cwd: dirname(file) }); | ||
logger.log(`Write version ${version} to package.json in ${file}`); | ||
}); | ||
} | ||
|
||
async function publish({ packages }, context) { | ||
const { logger } = context; | ||
|
||
shell | ||
.ls(`${packages}/*/package.json`) | ||
.map(file => ({ pkgPath: dirname(file), package: JSON.parse(file) })) | ||
.forEach(({ pkgPath: packagePath, package }) => { | ||
shell.exec(`npm publish ${packagePath}`, { cwd: packagePath }); | ||
logger.log(`Published ${package.name}@${package.version}.`); | ||
}); | ||
} | ||
|
||
module.exports = { prepare, publish }; |