Skip to content

Commit feef548

Browse files
committed
Include version when building
1 parent 098f30a commit feef548

5 files changed

Lines changed: 43 additions & 31 deletions

File tree

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,11 @@ How to [secure your setup](/doc/security/ssl.md).
5656
directory which will cause issues because then `yarn watch` will try to
5757
compile the build directory as well.
5858
- For now `@coder/nbin` is a global dependency.
59-
- Run `yarn build ${vscodeVersion} ${target} ${arch}`in this directory (for example:
60-
`yarn build 1.35.0 linux x64`).
59+
- Run `yarn build ${codeServerVersion} ${vscodeVersion} ${target} ${arch}` in
60+
this directory (for example: `yarn build development 1.35.0 linux x64`).
61+
- You can run the built code with `node path/to/build/out/vs/server/main.js` or run
62+
`yarn binary` with the same arguments in the previous step to package the
63+
code into a single binary.
6164
6265
## Development
6366

scripts/ci.bash

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,51 @@
11
#!/bin/bash
22
set -euo pipefail
33

4-
# Build using a Docker container using the specified image and version.
4+
# Build using a Docker container.
55
function docker-build() {
6-
local image="${1}" ; shift
7-
local version="${1}" ; shift
8-
local vscodeVersion="${1}" ; shift
9-
local target="${1}" ; shift
10-
local arch="${1}" ; shift
11-
126
local containerId
137
containerId=$(docker create --network=host --rm -it -v "$(pwd)"/.cache:/src/.cache "${image}")
148
docker start "${containerId}"
159
docker exec "${containerId}" mkdir -p /src
1610

1711
function docker-exec() {
18-
docker exec "${containerId}" bash -c "$@"
12+
local command="${1}" ; shift
13+
local args="'${codeServerVersion}' '${vscodeVersion}' '${target}' '${arch}'"
14+
docker exec "${containerId}" \
15+
bash -c "cd /src && CI=true yarn ${command} ${args}"
1916
}
2017

2118
docker cp ./. "${containerId}":/src
22-
docker-exec "cd /src && CI=true yarn build \"${vscodeVersion}\" \"${target}\" \"${arch}\""
23-
docker-exec "cd /src && CI=true yarn binary \"${vscodeVersion}\" \"${target}\" \"${arch}\""
24-
docker-exec "cd /src && CI=true yarn package \"${vscodeVersion}\" \"${target}\" \"${arch}\" \"${version}\""
19+
docker-exec build
20+
docker-exec binary
21+
docker-exec package
2522
docker cp "${containerId}":/src/release/. ./release/
2623

2724
docker stop "${containerId}"
2825
}
2926

27+
# Build locally.
28+
function local-build() {
29+
function local-exec() {
30+
local command="${1}" ; shift
31+
CI=true yarn "${command}" \
32+
"${codeServerVersion}" "${vscodeVersion}" "${target}" "${arch}"
33+
}
34+
35+
local-exec build
36+
local-exec binary
37+
local-exec package
38+
}
39+
3040
# Build code-server in the CI.
3141
function main() {
32-
local version="${VERSION:-}"
42+
local codeServerVersion="${VERSION:-}"
3343
local vscodeVersion="${VSCODE_VERSION:-}"
3444
local ostype="${OSTYPE:-}"
3545
local target="${TARGET:-}"
3646
local arch=x64
3747

38-
if [[ -z "${version}" ]] ; then
48+
if [[ -z "${codeServerVersion}" ]] ; then
3949
>&2 echo "Must set VERSION environment variable"; exit 1
4050
fi
4151

@@ -45,9 +55,7 @@ function main() {
4555

4656
if [[ "${ostype}" == "darwin"* ]]; then
4757
target=darwin
48-
CI=true yarn build "${vscodeVersion}" "${target}" "${arch}"
49-
CI=true yarn binary "${vscodeVersion}" "${target}" "${arch}"
50-
CI=true yarn package "${vscodeVersion}" "${target}" "${arch}" "${version}"
58+
local-build
5159
else
5260
local image
5361
if [[ "${target}" == alpine ]]; then
@@ -57,7 +65,7 @@ function main() {
5765
image=codercom/nbin-centos
5866
target=linux
5967
fi
60-
docker-build "${image}" "${version}" "${vscodeVersion}" "${target}" "${arch}"
68+
docker-build
6169
fi
6270
}
6371

scripts/merge.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const fs = require("fs");
33
const a = process.argv[2];
44
const b = process.argv[3];
55
const out = process.argv[4];
6+
const json = JSON.parse(process.argv[5] || "{}");
67

78
const aJson = JSON.parse(fs.readFileSync(a));
89
const bJson = JSON.parse(fs.readFileSync(b));
@@ -15,4 +16,5 @@ delete aJson.optionalDependencies;
1516
fs.writeFileSync(out, JSON.stringify({
1617
...aJson,
1718
...bJson,
19+
...json,
1820
}, null, 2));

scripts/nbin-loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ if (!global.NBIN_LOADED) {
44
nbin.shimNativeFs("{{ROOT_PATH}}");
55
global.NBIN_LOADED = true;
66
} catch (error) {
7-
console.log("Not in the binary");
7+
// Not in the binary.
88
}
99
}

scripts/tasks.bash

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,10 @@ function build-code-server() {
7272
rm -rf "${codeServerBuildPath}"
7373
mkdir -p "${codeServerBuildPath}"
7474

75+
local json="{\"codeServerVersion\": \"${codeServerVersion}\"}"
76+
7577
cp -r "${vscodeBuildPath}/resources/app/extensions" "${codeServerBuildPath}"
76-
node "${rootPath}/scripts/merge.js" "${vscodeBuildPath}/resources/app/package.json" "${rootPath}/scripts/package.json" "${codeServerBuildPath}/package.json"
78+
node "${rootPath}/scripts/merge.js" "${vscodeBuildPath}/resources/app/package.json" "${rootPath}/scripts/package.json" "${codeServerBuildPath}/package.json" "${json}"
7779
node "${rootPath}/scripts/merge.js" "${vscodeBuildPath}/resources/app/product.json" "${rootPath}/scripts/product.json" "${codeServerBuildPath}/product.json"
7880
cp -r "${vscodeSourcePath}/out" "${codeServerBuildPath}"
7981
rm -rf "${codeServerBuildPath}/out/vs/server/node_modules"
@@ -187,12 +189,7 @@ function vstar-task() {
187189
}
188190

189191
function package-task() {
190-
local version="${1}" ; shift
191-
192-
log " version: ${version}"
193-
194-
local archiveName="code-server${version}-vsc${vscodeVersion}-${target}-${arch}"
195-
local archivePath="${releasePath}/${archiveName}"
192+
local archivePath="${releasePath}/${binaryName}"
196193
rm -rf "${archivePath}"
197194
mkdir -p "${archivePath}"
198195

@@ -203,10 +200,10 @@ function package-task() {
203200

204201
cd "${releasePath}"
205202
if [[ "${target}" == "linux" ]] ; then
206-
tar -czf "${archiveName}.tar.gz" "${archiveName}"
203+
tar -czf "${binaryName}.tar.gz" "${binaryName}"
207204
log "Archive: ${archivePath}.tar.gz"
208205
else
209-
zip -r "${archiveName}.zip" "${archiveName}"
206+
zip -r "${binaryName}.zip" "${binaryName}"
210207
log "Archive: ${archivePath}.zip"
211208
fi
212209
}
@@ -226,6 +223,7 @@ function binary-task() {
226223

227224
function main() {
228225
local task="${1}" ; shift
226+
local codeServerVersion="${1}" ; shift
229227
local vscodeVersion="${1}" ; shift
230228
local target="${1}" ; shift
231229
local arch="${1}" ; shift
@@ -262,13 +260,14 @@ function main() {
262260
local vscodeSourcePath="${buildPath}/${vscodeSourceName}"
263261
local vscodeBuildPath="${buildPath}/${vscodeBuildName}"
264262

265-
local codeServerBuildName="code-server-${vscodeVersion}-${target}-${arch}-built"
263+
local codeServerBuildName="code-server${codeServerVersion}-vsc${vscodeVersion}-${target}-${arch}-built"
266264
local codeServerBuildPath="${buildPath}/${codeServerBuildName}"
267-
local binaryName="code-server-${vscodeVersion}-${target}-${arch}"
265+
local binaryName="code-server${codeServerVersion}-vsc${vscodeVersion}-${target}-${arch}"
268266

269267
log "Running ${task} task"
270268
log " rootPath: ${rootPath}"
271269
log " outPath: ${outPath}"
270+
log " codeServerVersion: ${codeServerVersion}"
272271
log " vscodeVersion: ${vscodeVersion}"
273272
log " target: ${target}"
274273
log " arch: ${arch}"

0 commit comments

Comments
 (0)