-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpackage.sh
More file actions
executable file
·30 lines (26 loc) · 1001 Bytes
/
package.sh
File metadata and controls
executable file
·30 lines (26 loc) · 1001 Bytes
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
#!/bin/sh -e
LAMBDAS=$1
npx webpack --env lambdas="${LAMBDAS}"
bundle_dir="build/bundle/"
artefact_dir="artefacts/"
version_num=$(jq -r '.version' < package.json | cut -d . -f 1,2).$(date +%s)
git_rev=$(git rev-parse --short HEAD)
mkdir -p ${artefact_dir}
functions=$(npx yaml2json serverless.yml | jq -r '.functions | keys | .[]')
for func_name in ${functions}; do
if [ -z "${LAMBDAS}" ] || echo "${LAMBDAS}" | grep "${func_name}"; then
bundle_path="${bundle_dir}${func_name}.js"
zip_filename="${func_name}-${version_num}-${git_rev}.zip"
zip_path="${artefact_dir}${zip_filename}"
zip -Xj "${zip_path}" "${bundle_path}"
echo "LAMBDA ARTIFACT: ${bundle_path} => ${zip_path}"
fi
done
if [ -d coverage ]; then
coverage_filename="result-processing-coverage-${version_num}-${git_rev}.zip"
coverage_path="${artefact_dir}${coverage_filename}"
zip "${coverage_path}" coverage
echo "COVERAGE ARTIFACT: coverage => ${coverage_path}"
else
echo "No coverage report found"
fi