Skip to content

Commit 04adf14

Browse files
committed
Move OSX package task into build script
This is to match how the other binaries are built. Also made some changes to make the Docker containers clean up for when you are running this locally.
1 parent 406ec0b commit 04adf14

File tree

3 files changed

+42
-22
lines changed

3 files changed

+42
-22
lines changed

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ before_deploy:
2727
- git config --local user.name "$USER_NAME"
2828
- git config --local user.email "$USER_EMAIL"
2929
- git tag "$VERSION" "$TRAVIS_COMMIT"
30-
- if [[ “$TRAVIS_OS_NAME” == “osx” ]]; then yarn task package $VERSION; fi
3130
deploy:
3231
provider: releases
3332
file_glob: true

build/tasks.ts

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ const buildServerBinary = register("build:server:binary", async (runner) => {
2121
logger.info("Building with environment", field("env", {
2222
NODE_ENV: process.env.NODE_ENV,
2323
VERSION: process.env.VERSION,
24+
OSTYPE: process.env.OSTYPE,
25+
TARGET: process.env.TARGET,
2426
}));
2527

2628
await ensureInstalled();

scripts/build.sh

+40-21
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,51 @@
11
#!/bin/bash
22
set -euxo pipefail
33

4-
# Variables to be set:
5-
# $IMAGE
4+
# Build using a Docker container using the specified image and version.
65
function docker_build() {
7-
containerID=$(docker create -it -v $(pwd)/.cache:/src/.cache $IMAGE)
8-
docker start $containerID
9-
docker exec $containerID mkdir -p /src
6+
local image="${1}" ; shift
7+
local version="${1}" ; shift
108

11-
function exec() {
12-
docker exec $containerID bash -c "$@"
9+
local containerId
10+
containerId=$(docker create --network=host --rm -it -v "$(pwd)"/.cache:/src/.cache "${image}")
11+
docker start "${containerId}"
12+
docker exec "${containerId}" mkdir -p /src
13+
14+
function docker_exec() {
15+
docker exec "${containerId}" bash -c "$@"
1316
}
1417

15-
docker cp ./. $containerID:/src
16-
exec "cd /src && yarn"
17-
exec "cd /src && npm rebuild"
18-
exec "cd /src && NODE_ENV=production VERSION=$VERSION yarn task build:server:binary"
19-
exec "cd /src && yarn task package $VERSION"
20-
docker cp $containerID:/src/release/. ./release/
18+
docker cp ./. "${containerId}":/src
19+
docker_exec "cd /src && yarn"
20+
docker_exec "cd /src && npm rebuild"
21+
docker_exec "cd /src && NODE_ENV=production VERSION=${version} yarn task build:server:binary"
22+
docker_exec "cd /src && yarn task package ${version}"
23+
docker cp "${containerId}":/src/release/. ./release/
24+
25+
docker stop "${containerId}"
2126
}
2227

23-
if [[ "$OSTYPE" == "darwin"* ]]; then
24-
NODE_ENV=production yarn task build:server:binary
25-
else
26-
if [[ "$TARGET" == "alpine" ]]; then
27-
IMAGE="codercom/nbin-alpine"
28+
function main() {
29+
local version=${VERSION:-}
30+
local ostype=${OSTYPE:-}
31+
32+
if [[ -z "${version}" ]] ; then
33+
>&2 echo "Must set VERSION environment variable"
34+
exit 1
35+
fi
36+
37+
if [[ "${ostype}" == "darwin"* ]]; then
38+
NODE_ENV=production VERSION="${version}" yarn task build:server:binary
39+
yarn task package "${version}"
2840
else
29-
IMAGE="codercom/nbin-centos"
41+
local image
42+
if [[ "$TARGET" == "alpine" ]]; then
43+
image="codercom/nbin-alpine"
44+
else
45+
image="codercom/nbin-centos"
46+
fi
47+
docker_build "${image}" "${version}"
3048
fi
31-
docker_build
32-
fi
49+
}
50+
51+
main "$@"

0 commit comments

Comments
 (0)