Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Commit

Permalink
ci: create a semantic-release plugin to release multiple packages
Browse files Browse the repository at this point in the history
  • Loading branch information
klemenoslaj committed Apr 17, 2019
1 parent c0b3b7b commit e7e6512
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false

[*.json]
indent_size = 2
8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ notifications:
node_js:
- "10"
- "8"
before_script:
- yarn global add @angular/cli
script:
- yarn commitlint-travis
- ng build core
- ng test core --watch false
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
- yarn build
- yarn test:once
- cat ./coverage/core/lcov.info | ./node_modules/coveralls/bin/coveralls.js
after_success:
- yarn travis-deploy-once "yarn semantic-release"
branches:
Expand Down
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"url": "https://github.com/klemenoslaj/ng-action-outlet.git"
},
"scripts": {
"build": "yarn build:core",
"build:core": "ng build core",
"test:once": "ng test core --watch false --browsers ChromiumHeadless --code-coverage",
"docs:coverage": "compodoc -p ./tsconfig.docs.json --disableLifeCycleHooks --disableInternal --coverageMinimumPerFile 100",
"docs:build.prod": "yarn docs:coverage && compodoc -p ./tsconfig.docs.json --disableLifeCycleHooks --disableInternal --disablePrivate --disableProtected --name NgActionOutlet --output docs",
"docs:build.serve": "compodoc -p ./tsconfig.docs.json --disableLifeCycleHooks --disableInternal -s -w",
Expand Down Expand Up @@ -58,14 +60,21 @@
"remark-cli": "^6.0.1",
"remark-preset-lint-recommended": "^3.0.2",
"semantic-release": "^15.10.5",
"shelljs": "^0.8.3",
"ts-node": "~7.0.0",
"tsickle": ">=0.29.0",
"tslib": "^1.9.0",
"tslint": "^5.13.0",
"typescript": "~3.2.0"
},
"release": {
"pkgRoot": "dist/core"
"packages": "dist",
"plugins": [
"./scripts/release.js",
"@semantic-release/github",
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator"
]
},
"config": {
"commitizen": {
Expand Down
17 changes: 5 additions & 12 deletions projects/core/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html

let reports = ['html', 'lcovonly', 'text'];
let browsers = ['Chromium', 'ChromiumHeadless'];

if (process.env.TRAVIS) {
reports = ['lcovonly'];
browsers = ['ChromiumHeadless'];
}

module.exports = function (config) {
config.set({
basePath: '',
Expand All @@ -24,16 +16,17 @@ module.exports = function (config) {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../../coverage'),
reports: reports,
dir: require('path').join(__dirname, '../../coverage/core'),
reports: ['html', 'lcovonly'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: browsers,
singleRun: false
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true
});
};
29 changes: 29 additions & 0 deletions scripts/release.js
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 };

0 comments on commit e7e6512

Please sign in to comment.