mirror of
https://github.com/cdr/code-server.git
synced 2026-03-31 18:44:46 +02:00
* Allow setting the VS Code build target For the NPM package (and tests, at least for now), we will still use linux-x64, but this is going to allow using the platform build targets for our standalone releases so we can avoid having to copy all the packaging steps (like cleaning up modules). This does mean that the NPM package when installed will be missing those cleanup steps. Possibly we can try to break out the packaging step into a something that can be ran standalone (which will also require installing dev dependencies like gulp) but not sure how much work this would be. * Preserve dependencies for e2e tests To avoid having to install them again. Also moved an env block to the root of the job. * Refactor releases to use VS Code packaging Instead of building the linux-x64 package, stripping the modules, then installing them again, we build the correct target and use the modules as they are. This means we do not have to copy all the post-processing steps like the ones that delete unnecessary modules. For the NPM package we still publish the linux-x64 package (without modules of course). This means npm installations do not get that same post-processing. Another advantage of this is that we can run the release immediately without having to wait for the build step, or on a commit that no longer has a build artifact, since they all build individually now. We could try sharing the core-ci build step, but leaving that alone for now. I also converted the macOS jobs into a matrix. Deleted the CI readme because it was out of date and seemed to just repeat what should be described in the scripts anyway. Removed a section about Homebrew since we do not maintain that anymore. It looks like there is no need to symlink node_modules.asar anymore.
148 lines
4.2 KiB
Bash
Executable file
148 lines
4.2 KiB
Bash
Executable file
#!/usr/bin/env sh
|
|
set -eu
|
|
|
|
# Copied from ../lib.sh except we do not rename Darwin and we do not need to
|
|
# detect Alpine.
|
|
os() {
|
|
osname=$(uname | tr '[:upper:]' '[:lower:]')
|
|
case $osname in
|
|
cygwin* | mingw*) osname="windows" ;;
|
|
esac
|
|
echo "$osname"
|
|
}
|
|
|
|
# Create a symlink at $2 pointing to $1 on any platform. Anything that
|
|
# currently exists at $2 will be deleted.
|
|
symlink() {
|
|
source="$1"
|
|
dest="$2"
|
|
rm -rf "$dest"
|
|
case $OS in
|
|
windows) mklink /J "$dest" "$source" ;;
|
|
*) ln -s "$source" "$dest" ;;
|
|
esac
|
|
}
|
|
|
|
# Make a symlink at bin/$1/$3 pointing to the platform-specific version of the
|
|
# script in $2. The extension of the link will be .cmd for Windows otherwise it
|
|
# will be whatever is in $4 (or no extension if $4 is not set).
|
|
symlink_bin_script() {
|
|
oldpwd="$(pwd)"
|
|
cd "bin/$1"
|
|
source="$2"
|
|
dest="$3"
|
|
ext="${4-}"
|
|
case $OS in
|
|
windows) symlink "$source.cmd" "$dest.cmd" ;;
|
|
darwin | macos) symlink "$source-darwin.sh" "$dest$ext" ;;
|
|
*) symlink "$source-linux.sh" "$dest$ext" ;;
|
|
esac
|
|
cd "$oldpwd"
|
|
}
|
|
|
|
command_exists() {
|
|
if [ ! "$1" ]; then return 1; fi
|
|
command -v "$@" > /dev/null
|
|
}
|
|
|
|
is_root() {
|
|
if command_exists id && [ "$(id -u)" = 0 ]; then
|
|
return 0
|
|
fi
|
|
return 1
|
|
}
|
|
|
|
OS="$(os)"
|
|
|
|
main() {
|
|
# Grabs the major version of node from $npm_config_user_agent which looks like
|
|
# yarn/1.21.1 npm/? node/v14.2.0 darwin x64
|
|
major_node_version=$(echo "$npm_config_user_agent" | sed -n 's/.*node\/v\([^.]*\).*/\1/p')
|
|
|
|
if [ -n "${FORCE_NODE_VERSION:-}" ]; then
|
|
echo "WARNING: Overriding required Node.js version to v$FORCE_NODE_VERSION"
|
|
echo "This could lead to broken functionality, and is unsupported."
|
|
echo "USE AT YOUR OWN RISK!"
|
|
fi
|
|
|
|
if [ "$major_node_version" -ne "${FORCE_NODE_VERSION:-22}" ]; then
|
|
echo "ERROR: code-server currently requires node v22."
|
|
if [ -n "$FORCE_NODE_VERSION" ]; then
|
|
echo "However, you have overrided the version check to use v$FORCE_NODE_VERSION."
|
|
fi
|
|
echo "We have detected that you are on node v$major_node_version"
|
|
echo "You can override this version check by setting \$FORCE_NODE_VERSION,"
|
|
echo "but configurations that do not use the same node version are unsupported."
|
|
exit 1
|
|
fi
|
|
|
|
# Under npm, if we are running as root, we need --unsafe-perm otherwise
|
|
# post-install scripts will not have sufficient permissions to do their thing.
|
|
if is_root; then
|
|
case "${npm_config_user_agent-}" in npm*)
|
|
if [ "${npm_config_unsafe_perm-}" != "true" ]; then
|
|
echo "Please pass --unsafe-perm to npm to install code-server"
|
|
echo "Otherwise post-install scripts will not have permissions to run"
|
|
echo "See https://docs.npmjs.com/misc/config#unsafe-perm"
|
|
echo "See https://stackoverflow.com/questions/49084929/npm-sudo-global-installation-unsafe-perm"
|
|
exit 1
|
|
fi
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
if ! vscode_install; then
|
|
echo "You may not have the required dependencies to build the native modules."
|
|
echo "Please see https://github.com/coder/code-server/blob/main/docs/npm.md"
|
|
exit 1
|
|
fi
|
|
|
|
if [ -n "${FORCE_NODE_VERSION:-}" ]; then
|
|
echo "WARNING: The required Node.js version was overriden to v$FORCE_NODE_VERSION"
|
|
echo "This could lead to broken functionality, and is unsupported."
|
|
echo "USE AT YOUR OWN RISK!"
|
|
fi
|
|
}
|
|
|
|
install_with_yarn_or_npm() {
|
|
echo "User agent: ${npm_config_user_agent-none}"
|
|
# For development we enforce npm, but for installing the package as an
|
|
# end-user we want to keep using whatever package manager is in use.
|
|
case "${npm_config_user_agent-}" in
|
|
npm*)
|
|
if ! npm install --unsafe-perm --omit=dev; then
|
|
return 1
|
|
fi
|
|
;;
|
|
yarn*)
|
|
if ! yarn --production --frozen-lockfile --no-default-rc; then
|
|
return 1
|
|
fi
|
|
;;
|
|
*)
|
|
echo "Could not determine which package manager is being used to install code-server"
|
|
exit 1
|
|
;;
|
|
esac
|
|
return 0
|
|
}
|
|
|
|
vscode_install() {
|
|
echo 'Installing Code dependencies...'
|
|
cd lib/vscode
|
|
if ! install_with_yarn_or_npm; then
|
|
return 1
|
|
fi
|
|
|
|
symlink_bin_script remote-cli code code-server
|
|
symlink_bin_script helpers browser browser .sh
|
|
|
|
cd extensions
|
|
if ! install_with_yarn_or_npm; then
|
|
return 1
|
|
fi
|
|
|
|
return 0
|
|
}
|
|
|
|
main "$@"
|