-
Notifications
You must be signed in to change notification settings - Fork 22
/
buildspec.yml
87 lines (81 loc) · 3.15 KB
/
buildspec.yml
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
version: 0.2
env:
shell: bash
exported-variables:
- BSS_IMAGE_ASSET_REPOSITORY_NAME
- BUILD_VERSION
- CN_ASSETS
- GLOBAL_ASSETS
- ECR_REPOS
- CN_ECR_REPOS
phases:
install:
runtime-versions:
nodejs: latest
commands:
- n 20.12.0
pre_build:
commands:
- |-
set -euxo pipefail
if [ "${IS_IN_GCR_PIPELINE-1}" == '0' ] || [ $DIST_OUTPUT_BUCKET != 'aws-gcr-solutions' ]; then
export BUILD_VERSION=$VERSION-$(/bin/date +"%Y%m%d%H%M")
export SOLUTION_VERSION=$BUILD_VERSION
export IS_IN_GCR_PIPELINE=0
else
FEATURE_NAME="${FEATURE_NAME:-""}"
export BSS_IMAGE_ASSET_REPOSITORY_NAME=$(echo "$SOLUTION_NAME" | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
export SOLUTION_ECR_REPO_NAME="$BSS_IMAGE_ASSET_REPOSITORY_NAME"
BUILD_VERSION=$(git describe --tags --always --abbrev=0 $(git rev-parse --short HEAD))
if [ "${BUILD_VERSION:0:1}" != v ]; then
BUILD_VERSION=latest
fi
if [ -n "$FEATURE_NAME" ]; then
BUILD_VERSION=$BUILD_VERSION-$FEATURE_NAME
fi
export BUILD_VERSION=${BUILD_VERSION}-$(/bin/date +"%Y%m%d%H%M")-$(git rev-parse --short HEAD)
export IS_IN_GCR_PIPELINE=1
export GLOBAL_ASSETS='default/'
export CN_ASSETS='cn/'
fi
echo BUILD_VERSION=$BUILD_VERSION
build:
commands:
- |-
set -euxo pipefail
if [ $IS_IN_GCR_PIPELINE -eq 1 ]; then
${CODEBUILD_SRC_DIR}/deployment/build-s3-dist-1.sh ${DIST_OUTPUT_BUCKET} ${SOLUTION_NAME} ${BUILD_VERSION}
mkdir -p deployment/open-source/ && touch deployment/open-source/.empty
fi
if [ $IS_IN_GCR_PIPELINE -eq 0 ]; then
echo "Starting build `date` in `pwd`"
[ ! -z $SOLUTION_VERSION ] && {
if [ $(echo $SOLUTION_VERSION | grep 'v[0-9]\+\.[0-9]\+\.[0-9]\+') ]; then
echo "SOLUTION_VERSION: $SOLUTION_VERSION"
else
echo "SOLUTION_VERSION: $SOLUTION_VERSION is not as expected, unset it"
unset SOLUTION_VERSION
fi
}
bash ${CODEBUILD_SRC_DIR}/deployment/run-unit-tests.sh
cd ${CODEBUILD_SRC_DIR}/deployment/
if [ -n "$VERSION" ]; then
chmod +x ./build-s3-dist.sh && ./build-s3-dist.sh $DIST_OUTPUT_BUCKET $SOLUTION_NAME ${VERSION}
else
chmod +x ./build-s3-dist.sh && ./build-s3-dist.sh $DIST_OUTPUT_BUCKET $SOLUTION_NAME ${BUILD_VERSION}
fi
echo "Build completed `date`"
echo "Starting open-source-dist `date` in `pwd`"
chmod +x ./build-open-source-dist.sh && ./build-open-source-dist.sh $SOLUTION_NAME
echo "Open Source Dist completed `date`"
fi
post_build:
commands:
- |-
set -euxo pipefail
__dir="${CODEBUILD_SRC_DIR}/deployment"
function join_by { local IFS="$1"; shift; echo "$*"; }
export ECR_REPOS=$(join_by , `cat "${__dir}/ecr-repos"`)
artifacts:
files:
- '**/*'