diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 72b442b5..a67d0502 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -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 +``` + +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 --skip-git +``` diff --git a/package.json b/package.json index b554dcde..2f2f0415 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/release/publish.js b/scripts/release/publish.js index 1ff45f8c..202ce990 100644 --- a/scripts/release/publish.js +++ b/scripts/release/publish.js @@ -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(' && ')); diff --git a/website/package.json b/website/package.json index 3427ef6b..95b2d97a 100644 --- a/website/package.json +++ b/website/package.json @@ -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 -" },