Skip to content

Clean shell scripts #7826

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 22, 2018
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
18 changes: 10 additions & 8 deletions scripts/release-weex.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
set -e
CUR_VERSION=`node build/get-weex-version.js -c`
NEXT_VERSION=`node build/get-weex-version.js`
CUR_VERSION=$(node build/get-weex-version.js -c)
NEXT_VERSION=$(node build/get-weex-version.js)

echo "Current: $CUR_VERSION"
read -p "Enter new version ($NEXT_VERSION): " -n 1 -r
Expand All @@ -20,15 +21,16 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then
WEEX_VERSION=$NEXT_VERSION npm run build:weex

# update package
cd packages/weex-vue-framework
npm version $NEXT_VERSION
# using subshells to avoid having to cd back
( cd packages/weex-vue-framework
npm version "$NEXT_VERSION"
npm publish
cd -
)

cd packages/weex-template-compiler
npm version $NEXT_VERSION
( cd packages/weex-template-compiler
npm version "$NEXT_VERSION"
npm publish
cd -
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice trick! Though I'm not sure if it'd be clear for everyone what is it doing. I'd stick with the cd - just for clarity.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add a comment like: using a subshell to avoid having to cd back.

It's not just to avoid writing a line, it also can prevent some troubles, see SC2013.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I didn't know about that one! It should be modified then. The comment would be helpful :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


# commit
git add packages/weex*
Expand Down
24 changes: 13 additions & 11 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/bin/bash
set -e

if [[ -z $1 ]]; then
echo "Enter new version: "
read VERSION
read -r VERSION
else
VERSION=$1
fi
Expand Down Expand Up @@ -32,23 +33,24 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then
VERSION=$VERSION npm run build

# update packages
cd packages/vue-template-compiler
npm version $VERSION
# using subshells to avoid having to cd back
( ( cd packages/vue-template-compiler
npm version "$VERSION"
if [[ -z $RELEASE_TAG ]]; then
npm publish
else
npm publish --tag $RELEASE_TAG
npm publish --tag "$RELEASE_TAG"
fi
cd -
)

cd packages/vue-server-renderer
npm version $VERSION
npm version "$VERSION"
if [[ -z $RELEASE_TAG ]]; then
npm publish
else
npm publish --tag $RELEASE_TAG
npm publish --tag "$RELEASE_TAG"
fi
cd -
)

# commit
git add -A
Expand All @@ -63,14 +65,14 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then
# generate release note
npm run release:note
# tag version
npm version $VERSION --message "build: release $VERSION"
npm version "$VERSION" --message "build: release $VERSION"

# publish
git push origin refs/tags/v$VERSION
git push origin refs/tags/v"$VERSION"
git push
if [[ -z $RELEASE_TAG ]]; then
npm publish
else
npm publish --tag $RELEASE_TAG
npm publish --tag "$RELEASE_TAG"
fi
fi