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