-
Notifications
You must be signed in to change notification settings - Fork 10
/
prepare-release.sh
executable file
·46 lines (39 loc) · 1.45 KB
/
prepare-release.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
if [ "$1" == "" ]; then
echo "Expected usage:"
echo "./prepare-release.sh [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease [--preid=<prerelease-id>] | from-git]"
exit 1
fi
set -Eux -o pipefail -o functrace
trap 'echo "ATTENTION: the last command had a non-zero exit status"; if [ "$BASH_COMMAND" != "npm audit fix" ]; then exit 1; fi' ERR
npm_version="$*"
set +x
echo "Preparing release '$npm_version'"
set -x
# Find all package.json files in subdirectories, except node_modules, examples, yivi-popup and yivi-frontend
standalone_packages=`find . -mindepth 2 -name "package.json" -not -path "*/node_modules/*" -not -path "*/examples/*" -not -path "*/yivi-popup/*" -not -path "*/yivi-frontend/*"`
# Loop over directories where package.json files are found and prepare for release
root=`pwd`
for package in ${standalone_packages[@]}; do
dirname=`dirname $package`
cd $dirname
set +x
echo "Preparing $dirname for release"
set -x
rm -rf ./node_modules ./dist
npm install
npm audit fix
npm update
npm run clean --if-present
npm run release --if-present
eval "npm version $npm_version --no-git-tag-version"
# Make sure dev dependencies are not included to prevent artifact pollution
rm -rf ./node_modules
npm install --only=prod
cd $root
done
set +x
echo ""
echo "Preparing for release done."
echo "Please check whether all output satisfies you."
echo "If you are happy, you can run ./release.sh"