浏览代码

wip lerna

Renée Kooi 6 年之前
父节点
当前提交
465468a1d4
共有 3 个文件被更改,包括 39 次插入5 次删除
  1. 8 5
      bin/release
  2. 30 0
      bin/sync-version-numbers
  3. 1 0
      package.json

+ 8 - 5
bin/release

@@ -47,7 +47,7 @@ set -o xtrace
 # Update README before publishing `uppy`
 # So up-to-date contributors are shown on the npm page.
 npm run contributors:save
-git commit -m "Update contributors" README.md
+git add README.md
 
 # Add readme file to the main `uppy` package.
 cp README.md packages/uppy/README.md
@@ -55,13 +55,16 @@ cp README.md packages/uppy/README.md
 npm run clean
 npm run build
 
-lerna publish --message="Release" --exact
+git commit -m "Release"
+lerna version --amend --no-push --exact
 
 # Replace version numbers in URLs
 version_files="./examples/ README.md bin/upload-to-cdn.sh website/src/examples/ website/src/docs/ website/themes/uppy/layout/"
 main_package_version=$(node -p "require('./packages/uppy/package.json').version")
 replace-x -r 'uppy/v\d+\.\d+\.\d+/dist' "uppy/v$main_package_version/dist" $version_files --exclude=node_modules
-git commit -m "Change Uppy version references to v$main_package_version" $version_files
+git commit --amend --no-edit $version_files # add changes to the Release commit
 
-git push
-git push --tags
+lerna publish from-git
+
+# git push
+# git push --tags

+ 30 - 0
bin/sync-version-numbers

@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+
+# Called by the `version` npm script.
+# This is run _after_ lerna updates the version numbers,
+# but _before_ it commits, so we have time to update the
+# version numbers throughout the repo and add it to the
+# release commit.
+# NOTE this _amends_ the previous commit, which should
+# already be a "Release" commit generated by bin/release.
+
+set -o pipefail
+set -o errexit
+set -o nounset
+
+# Set magic variables for current file & dir
+__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+__file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
+__base="$(basename ${__file} .sh)"
+__root="$(cd "$(dirname "${__dir}")" && pwd)"
+
+commit_message="$(git log -1 --pretty=%B)"
+if [ "$commit_message" != "Release" ]; then
+  echo "Last commit is not a release commit, but '$commit_message'"
+  exit 1
+fi
+
+version_files="./examples/ README.md bin/upload-to-cdn.sh website/src/examples/ website/src/docs/ website/themes/uppy/layout/"
+main_package_version=$(node -p "require('./packages/uppy/package.json').version")
+replace-x -r 'uppy/v\d+\.\d+\.\d+/dist' "uppy/v$main_package_version/dist" $version_files --exclude=node_modules
+git commit --amend --no-edit $version_files # add changes to the Release commit

+ 1 - 0
package.json

@@ -91,6 +91,7 @@
     "lint": "eslint . --cache",
     "lint-staged": "lint-staged",
     "release": "./bin/release",
+    "version": "./bin/sync-version-numbers",
     "start:companion": "sh ./bin/companion",
     "start": "npm-run-all --parallel watch start:companion web:preview",
     "test:registry": "verdaccio --listen 4002 --config test/endtoend/verdaccio.yaml",