Include version when building
This commit is contained in:
parent
09e3cfd881
commit
2fdf09e6e7
|
@ -56,8 +56,11 @@ How to [secure your setup](/doc/security/ssl.md).
|
|||
directory which will cause issues because then `yarn watch` will try to
|
||||
compile the build directory as well.
|
||||
- For now `@coder/nbin` is a global dependency.
|
||||
- Run `yarn build ${vscodeVersion} ${target} ${arch}`in this directory (for example:
|
||||
`yarn build 1.35.0 linux x64`).
|
||||
- Run `yarn build ${codeServerVersion} ${vscodeVersion} ${target} ${arch}` in
|
||||
this directory (for example: `yarn build development 1.35.0 linux x64`).
|
||||
- You can run the built code with `node path/to/build/out/vs/server/main.js` or run
|
||||
`yarn binary` with the same arguments in the previous step to package the
|
||||
code into a single binary.
|
||||
|
||||
## Development
|
||||
|
||||
|
|
|
@ -1,41 +1,51 @@
|
|||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
# Build using a Docker container using the specified image and version.
|
||||
# Build using a Docker container.
|
||||
function docker-build() {
|
||||
local image="${1}" ; shift
|
||||
local version="${1}" ; shift
|
||||
local vscodeVersion="${1}" ; shift
|
||||
local target="${1}" ; shift
|
||||
local arch="${1}" ; shift
|
||||
|
||||
local containerId
|
||||
containerId=$(docker create --network=host --rm -it -v "$(pwd)"/.cache:/src/.cache "${image}")
|
||||
docker start "${containerId}"
|
||||
docker exec "${containerId}" mkdir -p /src
|
||||
|
||||
function docker-exec() {
|
||||
docker exec "${containerId}" bash -c "$@"
|
||||
local command="${1}" ; shift
|
||||
local args="'${codeServerVersion}' '${vscodeVersion}' '${target}' '${arch}'"
|
||||
docker exec "${containerId}" \
|
||||
bash -c "cd /src && CI=true yarn ${command} ${args}"
|
||||
}
|
||||
|
||||
docker cp ./. "${containerId}":/src
|
||||
docker-exec "cd /src && CI=true yarn build \"${vscodeVersion}\" \"${target}\" \"${arch}\""
|
||||
docker-exec "cd /src && CI=true yarn binary \"${vscodeVersion}\" \"${target}\" \"${arch}\""
|
||||
docker-exec "cd /src && CI=true yarn package \"${vscodeVersion}\" \"${target}\" \"${arch}\" \"${version}\""
|
||||
docker-exec build
|
||||
docker-exec binary
|
||||
docker-exec package
|
||||
docker cp "${containerId}":/src/release/. ./release/
|
||||
|
||||
docker stop "${containerId}"
|
||||
}
|
||||
|
||||
# Build locally.
|
||||
function local-build() {
|
||||
function local-exec() {
|
||||
local command="${1}" ; shift
|
||||
CI=true yarn "${command}" \
|
||||
"${codeServerVersion}" "${vscodeVersion}" "${target}" "${arch}"
|
||||
}
|
||||
|
||||
local-exec build
|
||||
local-exec binary
|
||||
local-exec package
|
||||
}
|
||||
|
||||
# Build code-server in the CI.
|
||||
function main() {
|
||||
local version="${VERSION:-}"
|
||||
local codeServerVersion="${VERSION:-}"
|
||||
local vscodeVersion="${VSCODE_VERSION:-}"
|
||||
local ostype="${OSTYPE:-}"
|
||||
local target="${TARGET:-}"
|
||||
local arch=x64
|
||||
|
||||
if [[ -z "${version}" ]] ; then
|
||||
if [[ -z "${codeServerVersion}" ]] ; then
|
||||
>&2 echo "Must set VERSION environment variable"; exit 1
|
||||
fi
|
||||
|
||||
|
@ -45,9 +55,7 @@ function main() {
|
|||
|
||||
if [[ "${ostype}" == "darwin"* ]]; then
|
||||
target=darwin
|
||||
CI=true yarn build "${vscodeVersion}" "${target}" "${arch}"
|
||||
CI=true yarn binary "${vscodeVersion}" "${target}" "${arch}"
|
||||
CI=true yarn package "${vscodeVersion}" "${target}" "${arch}" "${version}"
|
||||
local-build
|
||||
else
|
||||
local image
|
||||
if [[ "${target}" == alpine ]]; then
|
||||
|
@ -57,7 +65,7 @@ function main() {
|
|||
image=codercom/nbin-centos
|
||||
target=linux
|
||||
fi
|
||||
docker-build "${image}" "${version}" "${vscodeVersion}" "${target}" "${arch}"
|
||||
docker-build
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ const fs = require("fs");
|
|||
const a = process.argv[2];
|
||||
const b = process.argv[3];
|
||||
const out = process.argv[4];
|
||||
const json = JSON.parse(process.argv[5] || "{}");
|
||||
|
||||
const aJson = JSON.parse(fs.readFileSync(a));
|
||||
const bJson = JSON.parse(fs.readFileSync(b));
|
||||
|
@ -15,4 +16,5 @@ delete aJson.optionalDependencies;
|
|||
fs.writeFileSync(out, JSON.stringify({
|
||||
...aJson,
|
||||
...bJson,
|
||||
...json,
|
||||
}, null, 2));
|
||||
|
|
|
@ -4,6 +4,6 @@ if (!global.NBIN_LOADED) {
|
|||
nbin.shimNativeFs("{{ROOT_PATH}}");
|
||||
global.NBIN_LOADED = true;
|
||||
} catch (error) {
|
||||
console.log("Not in the binary");
|
||||
// Not in the binary.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,8 +72,10 @@ function build-code-server() {
|
|||
rm -rf "${codeServerBuildPath}"
|
||||
mkdir -p "${codeServerBuildPath}"
|
||||
|
||||
local json="{\"codeServerVersion\": \"${codeServerVersion}\"}"
|
||||
|
||||
cp -r "${vscodeBuildPath}/resources/app/extensions" "${codeServerBuildPath}"
|
||||
node "${rootPath}/scripts/merge.js" "${vscodeBuildPath}/resources/app/package.json" "${rootPath}/scripts/package.json" "${codeServerBuildPath}/package.json"
|
||||
node "${rootPath}/scripts/merge.js" "${vscodeBuildPath}/resources/app/package.json" "${rootPath}/scripts/package.json" "${codeServerBuildPath}/package.json" "${json}"
|
||||
node "${rootPath}/scripts/merge.js" "${vscodeBuildPath}/resources/app/product.json" "${rootPath}/scripts/product.json" "${codeServerBuildPath}/product.json"
|
||||
cp -r "${vscodeSourcePath}/out" "${codeServerBuildPath}"
|
||||
rm -rf "${codeServerBuildPath}/out/vs/server/node_modules"
|
||||
|
@ -187,12 +189,7 @@ function vstar-task() {
|
|||
}
|
||||
|
||||
function package-task() {
|
||||
local version="${1}" ; shift
|
||||
|
||||
log " version: ${version}"
|
||||
|
||||
local archiveName="code-server${version}-vsc${vscodeVersion}-${target}-${arch}"
|
||||
local archivePath="${releasePath}/${archiveName}"
|
||||
local archivePath="${releasePath}/${binaryName}"
|
||||
rm -rf "${archivePath}"
|
||||
mkdir -p "${archivePath}"
|
||||
|
||||
|
@ -203,10 +200,10 @@ function package-task() {
|
|||
|
||||
cd "${releasePath}"
|
||||
if [[ "${target}" == "linux" ]] ; then
|
||||
tar -czf "${archiveName}.tar.gz" "${archiveName}"
|
||||
tar -czf "${binaryName}.tar.gz" "${binaryName}"
|
||||
log "Archive: ${archivePath}.tar.gz"
|
||||
else
|
||||
zip -r "${archiveName}.zip" "${archiveName}"
|
||||
zip -r "${binaryName}.zip" "${binaryName}"
|
||||
log "Archive: ${archivePath}.zip"
|
||||
fi
|
||||
}
|
||||
|
@ -226,6 +223,7 @@ function binary-task() {
|
|||
|
||||
function main() {
|
||||
local task="${1}" ; shift
|
||||
local codeServerVersion="${1}" ; shift
|
||||
local vscodeVersion="${1}" ; shift
|
||||
local target="${1}" ; shift
|
||||
local arch="${1}" ; shift
|
||||
|
@ -262,13 +260,14 @@ function main() {
|
|||
local vscodeSourcePath="${buildPath}/${vscodeSourceName}"
|
||||
local vscodeBuildPath="${buildPath}/${vscodeBuildName}"
|
||||
|
||||
local codeServerBuildName="code-server-${vscodeVersion}-${target}-${arch}-built"
|
||||
local codeServerBuildName="code-server${codeServerVersion}-vsc${vscodeVersion}-${target}-${arch}-built"
|
||||
local codeServerBuildPath="${buildPath}/${codeServerBuildName}"
|
||||
local binaryName="code-server-${vscodeVersion}-${target}-${arch}"
|
||||
local binaryName="code-server${codeServerVersion}-vsc${vscodeVersion}-${target}-${arch}"
|
||||
|
||||
log "Running ${task} task"
|
||||
log " rootPath: ${rootPath}"
|
||||
log " outPath: ${outPath}"
|
||||
log " codeServerVersion: ${codeServerVersion}"
|
||||
log " vscodeVersion: ${vscodeVersion}"
|
||||
log " target: ${target}"
|
||||
log " arch: ${arch}"
|
||||
|
|
Loading…
Reference in New Issue