2021-10-26 04:31:49 -04:00
|
|
|
#!/bin/bash
|
2021-10-28 06:27:35 -04:00
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one
|
|
|
|
# or more contributor license agreements. See the NOTICE file
|
|
|
|
# distributed with this work for additional information
|
|
|
|
# regarding copyright ownership. The ASF licenses this file
|
|
|
|
# to you under the Apache License, Version 2.0 (the
|
|
|
|
# "License"); you may not use this file except in compliance
|
|
|
|
# with the License. You may obtain a copy of the License at
|
2021-11-15 04:57:37 -05:00
|
|
|
#
|
2021-10-28 06:27:35 -04:00
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
2021-11-15 04:57:37 -05:00
|
|
|
#
|
2021-10-28 06:27:35 -04:00
|
|
|
# Unless required by applicable law or agreed to in writing,
|
|
|
|
# software distributed under the License is distributed on an
|
|
|
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
# KIND, either express or implied. See the License for the
|
|
|
|
# specific language governing permissions and limitations
|
|
|
|
# under the License.
|
2021-10-27 10:18:23 -04:00
|
|
|
rootDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
|
2021-10-26 04:31:49 -04:00
|
|
|
|
|
|
|
lernaVersionArg="$1"
|
|
|
|
if [[ -z $lernaVersionArg ]]; then
|
2021-11-03 07:22:57 -04:00
|
|
|
echo '[ERROR] Please provide argument for "lerna version".'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
currentNpm=$(npm --version)
|
|
|
|
npmVersion=$(node -e "process.stdout.write(require('./package.json').engines.npm)");
|
|
|
|
isSatisfiedNpm=$(node -e "process.stdout.write(require('semver').satisfies('$currentNpm', '$npmVersion').toString())");
|
|
|
|
|
|
|
|
currentNode=$(node --version)
|
|
|
|
nodeVersion=$(node -e "process.stdout.write(require('./package.json').engines.node)");
|
|
|
|
isSatisfiedNode=$(node -e "process.stdout.write(require('semver').satisfies('$currentNode', '$nodeVersion').toString())");
|
|
|
|
|
|
|
|
# Check node version compatible with package.json
|
|
|
|
if [[ $isSatisfiedNode != 'true' ]]; then
|
|
|
|
echo "[ERROR] Your node version($currentNode) is not compatible with package.json($nodeVersion)"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check npm version compatible with package.json
|
|
|
|
if [[ $isSatisfiedNpm != 'true' ]]; then
|
|
|
|
echo "[ERROR] Your npm version($currentNpm) is not compatible with package.json($npmVersion)"
|
2021-10-26 04:31:49 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Ignore Lerna's tag and push
|
|
|
|
lerna version $1 --no-push --no-git-tag-version --yes
|
|
|
|
|
|
|
|
if [[ -z $(git diff --stat) ]]; then
|
2021-11-03 07:22:57 -04:00
|
|
|
echo '[ERROR] No changed packages to version.'
|
2021-10-26 04:31:49 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Get the current tag version
|
|
|
|
tag=v$(node -e "process.stdout.write(require('./lerna.json').version)");
|
2021-12-22 03:26:12 -05:00
|
|
|
message="chore(plugins): publish $tag"
|
2021-10-26 04:31:49 -04:00
|
|
|
|
2021-10-27 10:18:23 -04:00
|
|
|
if [[ $? -ne 0 ]]; then
|
2021-11-03 07:22:57 -04:00
|
|
|
echo '[ERROR] Can not update package-lock.json'
|
2021-10-27 10:18:23 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-10-26 04:31:49 -04:00
|
|
|
# Auto-tag and auto-commit like usual
|
2021-10-27 11:23:13 -04:00
|
|
|
git commit --all -m "${message}"
|
2021-10-26 04:31:49 -04:00
|
|
|
git tag -a ${tag} -m ${tag}
|
|
|
|
git push origin ${tag}
|
|
|
|
git push
|