Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ test:
- yarn run validate
deployment:
release:
tag: /v[0-9]+(\.[0-9]+)*/
branch: master
owner: iopipe
commands:
# login using environment variables
- echo -e "$NPM_USERNAME\n$NPM_PASSWORD\n$NPM_EMAIL" | npm login
- npm publish
- yarn run release
24 changes: 17 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@iopipe/scripts",
"version": "1.1.1",
"version": "0.0.0-semantically-released",
"description": "CLI for common scripts for IOpipe projects",
"engines": {
"node": ">= 6.10",
Expand All @@ -11,15 +11,16 @@
},
"scripts": {
"add-contributor": "node src contributors add",
"test": "node src test",
"test:update": "node src test --updateSnapshot",
"build": "node src build",
"lint": "node src lint",
"format": "node src format",
"validate": "node src validate",
"lint": "node src lint",
"precommit": "node src precommit",
"prepare": "npm run build",
"prepublishOnly": "npm run build"
"prepublishOnly": "npm run build",
"release": "node src release",
"test": "node src test",
"test:update": "node src test --updateSnapshot",
"validate": "node src validate"
},
"files": [
"dist",
Expand All @@ -35,6 +36,8 @@
"dependencies": {
"@iopipe/eslint-config-iopipe": "1.0.2",
"@ljharb/eslint-config": "^12.2.1",
"@semantic-release/github": "^2.2.3",
"@semantic-release/npm": "^2.4.0",
"all-contributors-cli": "^4.9.1",
"arrify": "^1.0.1",
"babel-cli": "^6.26.0",
Expand Down Expand Up @@ -82,6 +85,7 @@
"rollup-plugin-node-globals": "^1.1.0",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-uglify": "^2.0.1",
"semantic-release": "^11.0.2",
"which": "^1.3.0",
"yargs-parser": "^8.0.0"
},
Expand Down Expand Up @@ -112,11 +116,17 @@
},
"homepage": "https://github.com/iopipe/iopipe-scripts#readme",
"devDependencies": {
"cz-conventional-changelog": "^2.1.0",
"jest-in-case": "^1.0.2",
"precommit": "^1.2.2",
"slash": "^1.0.0"
},
"pre-commit": [
"precommit"
]
],
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
}
}
2 changes: 1 addition & 1 deletion src/__tests__/__snapshots__/index.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ Available Scripts:
format
lint
precommit
release
test
travis-after-success
validate

Options:
Expand Down
27 changes: 27 additions & 0 deletions src/scripts/__tests__/__snapshots__/release.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`release calls concurrently with both scripts when on circle 1`] = `semantic-release --verify-conditions=@semantic-release/npm,@semantic-release/github`;

exports[`release does not do autorelease script when running on circle but in a pull request 1`] = `
Array [
Array [
Release conditions not met: should be in CI with pkg.version set correctly. Skipping release script.,
],
]
`;

exports[`release does not do the autorelease script when the version is different 1`] = `
Array [
Array [
Release conditions not met: should be in CI with pkg.version set correctly. Skipping release script.,
],
]
`;

exports[`release does not run either script when no coverage dir and not the right version 1`] = `
Array [
Array [
Release conditions not met: should be in CI with pkg.version set correctly. Skipping release script.,
],
]
`;
19 changes: 0 additions & 19 deletions src/scripts/__tests__/__snapshots__/travis-after-success.js.snap

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import { unquoteSerializer } from './helpers/serializers';
expect.addSnapshotSerializer(unquoteSerializer);

cases(
'travis-after-success',
'release',
({
version = '0.0.0-semantically-released',
hasCoverageDir = true,
isOptedOutOfCoverage = false,
env = {
TRAVIS: 'true',
TRAVIS_BRANCH: 'master',
TRAVIS_PULL_REQUEST: 'false'
CIRCLECI: 'true',
CIRCLE_BRANCH: 'master',
CI_PULL_REQUEST: 'false'
},
runsNothing = false
}) => {
Expand All @@ -38,7 +38,7 @@ cases(
}
utils.hasFile = () => hasCoverageDir;
process.env.SKIP_CODECOV = isOptedOutOfCoverage;
require('../travis-after-success');
require('../release');
if (runsNothing) {
expect(console.log.mock.calls).toMatchSnapshot();
} else {
Expand All @@ -57,22 +57,18 @@ cases(
jest.resetModules();
},
{
'calls concurrently with both scripts when on travis': {},
'calls concurrently with both scripts when on circle': {},
'does not do the autorelease script when the version is different': {
version: '1.2.3'
},
'does not do the codecov script when there is no coverage directory': {
hasCoverageDir: false
},
'does not do the codecov script when opted out': {
isOptedOutOfCoverage: true
version: '1.2.3',
runsNothing: true
},
'does not do autorelease script when running on travis but in a pull request': {
'does not do autorelease script when running on circle but in a pull request': {
env: {
TRAVIS: 'true',
TRAVIS_BRANCH: 'master',
TRAVIS_PULL_REQUEST: 'true'
}
CIRCLECI: 'true',
CIRCLE_BRANCH: 'master',
CI_PULL_REQUEST: 'true'
},
runsNothing: true
},
'does not run either script when no coverage dir and not the right version': {
runsNothing: true,
Expand Down
24 changes: 24 additions & 0 deletions src/scripts/release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const spawn = require('cross-spawn');
const { resolveBin, pkg, parseEnv } = require('../utils');

const shouldRelease = [
pkg.version === '0.0.0-semantically-released',
parseEnv('CIRCLECI', false),
process.env.CIRCLE_BRANCH === 'master',
!parseEnv('CI_PULL_REQUEST', false)
].every(Boolean);

if (shouldRelease) {
const result = spawn.sync(
resolveBin('semantic-release'),
['--verify-conditions=@semantic-release/npm,@semantic-release/github'],
{
stdio: 'inherit'
}
);
process.exit(result.status);
} else {
console.log(
'Release conditions not met: should be in CI with pkg.version set correctly. Skipping release script.'
);
}
40 changes: 0 additions & 40 deletions src/scripts/travis-after-success.js

This file was deleted.

Loading