mirror of
https://github.com/coder/code-server.git
synced 2025-07-30 05:22:04 +08:00
Include version when building
This commit is contained in:
@ -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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user