@@ -4,12 +4,85 @@ set -e -u -x -o pipefail
4
4
5
5
cd " $( dirname " $0 " ) /.."
6
6
7
- PLATFORM=" "
7
+ if [[ -z ${BUILDKITE+x} ]]; then
8
+ echo " This script is intended to run in CI only."
9
+ exit 1
10
+ fi
11
+
12
+ SPATIALOS_TOOLBELT_VERSION=" latest"
13
+
14
+ TOOLBELT_PLATFORM=" "
15
+ SPATIAL_PLATFORM=" "
16
+ SPATIAL_BINARY=" "
17
+
18
+ # Setup platform specific environment variables.
8
19
if [[ " $( uname -s) " == " Linux" ]]; then
9
- PLATFORM=" linux"
20
+ TOOLBELT_PLATFORM=" linux"
21
+ SPATIAL_PLATFORM=" linux"
22
+ SPATIAL_BINARY=" spatial"
10
23
elif [[ " $( uname -s) " == " Darwin" ]]; then
11
- PLATFORM=" macos"
24
+ TOOLBELT_PLATFORM=" mac"
25
+ SPATIAL_PLATFORM=" macos"
26
+ SPATIAL_BINARY=" spatial"
27
+
28
+ imp-tool-bootstrap subscribe \
29
+ --use_gcs_oidc_auth=false \
30
+ --gcs_credentials_type=auto \
31
+ --tools=imp-tool
32
+ else
33
+ TOOLBELT_PLATFORM=" win"
34
+ SPATIAL_PLATFORM=" windows"
35
+ SPATIAL_BINARY=" spatial.exe"
36
+ fi
37
+
38
+ # Create temporary directories for the spatial binary and authentication token.
39
+ export AUTH_DIR=" $( mktemp -d) "
40
+ export TOOLS_DIR=" $( mktemp -d) "
41
+
42
+ # Retrieve the authentication token.
43
+ if [[ " $SPATIAL_PLATFORM " == " macos" ]]; then
44
+ imp-vault read-key \
45
+ --environment=production \
46
+ --field=token \
47
+ --key=secret/sync.v1/dev-workflow/production-buildkite/buildkite-agents/spatialos-service-account/ci/improbable/worker-blank-projects-ci-token \
48
+ --vault_role=continuous-integration-production-improbable-iam \
49
+ --write_to=" ${AUTH_DIR} /oauth2_refresh_token"
50
+ else
51
+ imp-ci secrets read \
52
+ --environment=production \
53
+ --buildkite-org=improbable \
54
+ --secret-type=spatialos-service-account \
55
+ --secret-name=worker-blank-projects-ci-token \
56
+ --field=token \
57
+ --write-to=" ${AUTH_DIR} /oauth2_refresh_token"
58
+ fi
59
+
60
+ # Retrieve the spatial binary.
61
+ curl -Ls -o " ${TOOLS_DIR} /${SPATIAL_BINARY} .tmp" " https://console.improbable.io/toolbelt/download/${SPATIALOS_TOOLBELT_VERSION} /${TOOLBELT_PLATFORM} " || exit 1
62
+ chmod +x " ${TOOLS_DIR} /${SPATIAL_BINARY} .tmp"
63
+ mv " ${TOOLS_DIR} /${SPATIAL_BINARY} .tmp" " ${TOOLS_DIR} /${SPATIAL_BINARY} "
64
+
65
+ # Build
66
+ if [[ " $SPATIAL_PLATFORM " == " linux" ]]; then
67
+ docker build \
68
+ -t c_exampe_project_image \
69
+ -f ci/Dockerfile \
70
+ --build-arg USER_ID=$( id -u) \
71
+ --build-arg GROUP_ID=$( id -g) \
72
+ .
73
+ docker run \
74
+ --rm \
75
+ --volume " ${TOOLS_DIR} " :/build/tools \
76
+ --env TOOLS_DIR=/build/tools \
77
+ --volume " ${AUTH_DIR} " :/build/auth \
78
+ --env AUTH_DIR=/build/auth \
79
+ --volume $( pwd) :/code \
80
+ --workdir /code \
81
+ c_exampe_project_image \
82
+ /bin/bash -c ' export PATH="/code/ci:${PATH}"; \
83
+ spatial build --target ' " $SPATIAL_PLATFORM "
12
84
else
13
- PLATFORM=" windows"
85
+ # Add the spatial wrapper script to the path.
86
+ export PATH=" $( pwd) /ci" :" $PATH "
87
+ spatial build --target $SPATIAL_PLATFORM
14
88
fi
15
- spatial build --target $PLATFORM --log_level=debug
0 commit comments