-
Notifications
You must be signed in to change notification settings - Fork 0
/
pack.sh
executable file
·40 lines (33 loc) · 1.21 KB
/
pack.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
#!/bin/bash
# The purpose of this script is to prepare a "dist" directory
# according to the conventions of the Buildable pipeline, so
# that artifacts can be published to the various package managers
set -e
export PATH=$PWD/node_modules/.bin:$PATH
distdir="$PWD/dist"
rm -fr ${distdir}
mkdir -p ${distdir}
# run "npm run package" in all modules (which support it)
# this should emit a publishable to the "dist" directory of each module
lerna run package --stream
# collect all "dist" directories into "pack"
for dist in $(lerna exec "[ -d ./dist ] && echo \${PWD}/dist || true"); do
echo "collecting ${dist}..."
rsync -av ${dist}/ ${distdir}/
done
# create a build.json file with build metadata
# commit is obtained from CODEBUILD_RESOLVED_SOURCE_VERSION.
# if not defined (i.e. local build or CodePipeline build), use the HEAD commit hash
version="$(node -e "console.log(require('./lerna.json').version)")"
commit="${CODEBUILD_RESOLVED_SOURCE_VERSION:-"$(git rev-parse --verify HEAD)"}"
cat > ${distdir}/build.json <<HERE
{
"name": "jsii",
"version": "${version}",
"commit": "${commit}"
}
HERE
# copy CHANGELOG.md to dist/ for github releases
cp CHANGELOG.md ${distdir}/
# for posterity, print all files in dist
find dist/