Fix release script

This commit is contained in:
Nicolas Gallagher
2017-12-30 14:32:51 -08:00
parent 85aaa39206
commit bff3f50ae0
4 changed files with 54 additions and 14 deletions

View File

@@ -130,3 +130,18 @@ After you have submitted your pull request, we'll try to get back to you as
soon as possible. We may suggest some changes or improvements.
Thank you for contributing!
## Releases
To commit, publish, and push a final version:
```
yarn release <version>
```
Release candidates or versions that you'd like to publish to npm, but do not
want to produce a commit and push it to GitHub:
```
yarn release <version> --skip-git
```

View File

@@ -14,7 +14,9 @@
"lint": "yarn lint:check --fix",
"lint:check": "eslint packages scripts website",
"precommit": "lint-staged",
"release": "yarn test && yarn build && node ./scripts/release/publish.js && yarn docs:release",
"prerelease": "yarn test && yarn compile",
"release": "node ./scripts/release/publish.js",
"postrelease": "yarn docs:release",
"test": "yarn flow && yarn lint:check && yarn jest"
},
"devDependencies": {
@@ -43,7 +45,10 @@
"react-dom": "^16.2.0",
"react-test-renderer": "^16.2.0"
},
"workspaces": ["packages/*", "website"],
"workspaces": [
"packages/*",
"website"
],
"lint-staged": {
"**/*.js": [
"fmt:cmd",

View File

@@ -4,16 +4,36 @@
const execSync = require('child_process').execSync;
const version = process.argv.slice(2)[0];
const args = process.argv.slice(2);
const version = args[0];
const skipGit = args[1] === '--skip-git';
const releaseCommands = [
// use lerna to bump versions and dependencies
`./node_modules/.bin/lerna publish --skip-git --skip-npm --repo-version ${version} --yes`
];
if (!skipGit) {
releaseCommands.push(
...[
// add changes
'git add .',
// commit
`git commit -m "${version}"`,
// tag
`git tag -m ${version} "${version}"`
]
);
}
// publish to npm
releaseCommands.push('cd packages/babel-plugin-react-native-web && npm publish');
releaseCommands.push('cd ../react-native-web && npm publish');
if (!skipGit) {
// push to github
releaseCommands.push('git push --tags origin master');
}
console.log(`Publishing ${version}`);
// use lerna to bump versions and dependencies
execSync(`./node_modules/.bin/lerna publish --skip-git --skip-npm --repo-version ${version} --yes`);
// add changes
execSync('git add .');
// commit and tag
execSync(`git commit -m "${version}" && git tag -m ${version} "${version}"`);
// publish to npm
execSync('yarn publish');
// push to github
execSync('git push --tags origin master');
execSync(releaseCommands.join(' && '));

View File

@@ -3,7 +3,7 @@
"name": "website",
"version": "0.2.2",
"scripts": {
"build": "yarn && build-storybook -o ./dist -c ./storybook/.storybook",
"build": "build-storybook -o ./dist -c ./storybook/.storybook",
"start": "start-storybook -p 9001 -c ./storybook/.storybook",
"release": "yarn build && git checkout gh-pages && rm -rf ../storybook && mv dist ../storybook && git add -A && git commit -m \"Storybook deploy\" && git push origin gh-pages && git checkout -"
},