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.
This commit is contained in:
Asher 2026-03-27 11:24:34 -08:00
parent a5c1b6a196
commit 3f1a65005b
No known key found for this signature in database
GPG key ID: D63C1EF81242354A
5 changed files with 58 additions and 31 deletions

View file

@ -157,11 +157,14 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }} token: ${{ secrets.CODECOV_TOKEN }}
build: build:
name: Build code-server name: Build code-server npm package
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
env: env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
DISABLE_V8_COMPILE_CACHE: 1 DISABLE_V8_COMPILE_CACHE: 1
VERSION: 0.0.0
VSCODE_TARGET: linux-x64
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps: steps:
- uses: actions/checkout@v6 - uses: actions/checkout@v6
with: with:
@ -181,34 +184,29 @@ jobs:
test/package-lock.json test/package-lock.json
- run: SKIP_SUBMODULE_DEPS=1 npm ci - run: SKIP_SUBMODULE_DEPS=1 npm ci
- run: npm run build - run: npm run build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Get Code's git hash. When this changes it means the content is # Get Code's git hash. When this changes it means the content is
# different and we need to rebuild. # different and we need to rebuild.
- name: Get latest lib/vscode rev - name: Get latest lib/vscode rev
id: vscode-rev id: vscode-rev
run: echo "rev=$(git rev-parse HEAD:./lib/vscode)" >> $GITHUB_OUTPUT run: echo "rev=$(git rev-parse HEAD:./lib/vscode)" >> $GITHUB_OUTPUT
# We need to rebuild when we have a new version of Code, when any of # We need to rebuild when we have a new version of Code, when any of the
# the patches changed, or when the code-server version changes (since # patches changed, or when the code-server version changes (since it gets
# it gets embedded into the code). Use VSCODE_CACHE_VERSION to # embedded into the code). Use VSCODE_CACHE_VERSION to force a rebuild.
# force a rebuild. - name: Fetch prebuilt linux-x64 Code package from cache
- name: Fetch prebuilt Code package from cache
id: cache-vscode id: cache-vscode
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
path: lib/vscode-reh-web-* path: lib/vscode-reh-web-linux-x64-min-ci
key: vscode-reh-package-${{ secrets.VSCODE_CACHE_VERSION }}-${{ steps.vscode-rev.outputs.rev }}-${{ hashFiles('patches/*.diff', 'ci/build/build-vscode.sh') }} key: vscode-reh-linux-x64-package-${{ secrets.VSCODE_CACHE_VERSION }}-${{ steps.vscode-rev.outputs.rev }}-${{ hashFiles('patches/*.diff', 'ci/build/build-vscode.sh') }}
- name: Build vscode - name: Build vscode
env:
VERSION: "0.0.0"
if: steps.cache-vscode.outputs.cache-hit != 'true' if: steps.cache-vscode.outputs.cache-hit != 'true'
run: | run: |
pushd lib/vscode pushd lib/vscode
npm ci npm ci
popd popd
npm run build:vscode npm run build:vscode
# The release package does not contain any native modules # The release package is just the compiled code, does not contain any
# and is neutral to architecture/os/libc version. # native modules, and is thus neutral to architecture/os/libc version.
- run: npm run release - run: npm run release
if: success() if: success()
# https://github.com/actions/upload-artifact/issues/38 # https://github.com/actions/upload-artifact/issues/38

View file

@ -1,5 +1,4 @@
lib/vscode lib
lib/vscode-reh-web-linux-x64
release-standalone release-standalone
release-packages release-packages
release release

View file

@ -4,13 +4,16 @@ set -euo pipefail
# Once both code-server and VS Code have been built, use this script to copy # Once both code-server and VS Code have been built, use this script to copy
# them into a single directory (./release), prepare the package.json and # them into a single directory (./release), prepare the package.json and
# product.json, and add shrinkwraps. This results in a generic NPM package that # product.json, and add shrinkwraps. This results in a generic NPM package that
# we published to NPM and also use to compile platform-specific packages. # we can publish to NPM.
# MINIFY controls whether minified VS Code is bundled. It must match the value # MINIFY controls whether minified VS Code is bundled. It must match the value
# used when VS Code was built. # used when VS Code was built.
MINIFY="${MINIFY-true}" MINIFY="${MINIFY-true}"
# node_modules are not copied by default. Set KEEP_MODULES=1 to copy them. # node_modules are not copied by default. Set KEEP_MODULES=1 to copy them.
# Note these modules will be for the platform that built them, making the result
# no longer generic (it can still be published though as the modules will be
# ignored when pushing).
KEEP_MODULES="${KEEP_MODULES-0}" KEEP_MODULES="${KEEP_MODULES-0}"
main() { main() {
@ -85,7 +88,7 @@ bundle_vscode() {
rsync_opts+=(--exclude node_modules) rsync_opts+=(--exclude node_modules)
fi fi
rsync "${rsync_opts[@]}" ./lib/vscode-reh-web-*/ "$VSCODE_OUT_PATH" rsync "${rsync_opts[@]}" "./lib/vscode-reh-web-$VSCODE_TARGET/" "$VSCODE_OUT_PATH"
# Merge the package.json for the web/remote server so we can include # Merge the package.json for the web/remote server so we can include
# dependencies, since we want to ship this via NPM. # dependencies, since we want to ship this via NPM.

View file

@ -7,12 +7,12 @@ set -euo pipefail
MINIFY=${MINIFY-true} MINIFY=${MINIFY-true}
delete-bin-script() { delete-bin-script() {
rm -f "lib/vscode-reh-web-linux-x64/bin/$1" rm -f "lib/vscode-reh-web-$VSCODE_TARGET/bin/$1"
} }
copy-bin-script() { copy-bin-script() {
local script="$1" local script="$1"
local dest="lib/vscode-reh-web-linux-x64/bin/$script" local dest="lib/vscode-reh-web-$VSCODE_TARGET/bin/$script"
cp "lib/vscode/resources/server/bin/$script" "$dest" cp "lib/vscode/resources/server/bin/$script" "$dest"
sed -i.bak "s/@@VERSION@@/$(vscode_version)/g" "$dest" sed -i.bak "s/@@VERSION@@/$(vscode_version)/g" "$dest"
sed -i.bak "s/@@COMMIT@@/$BUILD_SOURCEVERSION/g" "$dest" sed -i.bak "s/@@COMMIT@@/$BUILD_SOURCEVERSION/g" "$dest"
@ -108,12 +108,8 @@ main() {
EOF EOF
) > product.json ) > product.json
# Any platform here works since we will do our own packaging. We have to do
# this because we have an NPM package that could be installed on any platform.
# The correct platform dependencies and scripts will be installed as part of
# the post-install during `npm install` or when building a standalone release.
npm run gulp core-ci npm run gulp core-ci
npm run gulp "vscode-reh-web-linux-x64${MINIFY:+-min}-ci" npm run gulp "vscode-reh-web-$VSCODE_TARGET${MINIFY:+-min}-ci"
# Reset so if you develop after building you will not be stuck with the wrong # Reset so if you develop after building you will not be stuck with the wrong
# commit (the dev client will use `oss-dev` but the dev server will still use # commit (the dev client will use `oss-dev` but the dev server will still use
@ -122,7 +118,7 @@ EOF
popd popd
pushd lib/vscode-reh-web-linux-x64 pushd "lib/vscode-reh-web-$VSCODE_TARGET"
# Make sure Code took the version we set in the environment variable. Not # Make sure Code took the version we set in the environment variable. Not
# having a version will break display languages. # having a version will break display languages.
if ! jq -e .commit product.json; then if ! jq -e .commit product.json; then

View file

@ -44,11 +44,42 @@ rsync() {
command rsync -a --del "$@" command rsync -a --del "$@"
} }
ARCH="$(arch)" if [[ ! ${ARCH-} ]]; then
export ARCH ARCH=$(arch)
OS=$(os) export ARCH
export OS fi
if [[ ! ${OS-} ]]; then
OS=$(os)
export OS
fi
# RELEASE_PATH is the destination directory for the release from the root. # RELEASE_PATH is the destination directory for the release from the root.
# Defaults to release # Defaults to release
RELEASE_PATH="${RELEASE_PATH-release}" if [[ ! ${RELEASE_PATH-} ]]; then
RELEASE_PATH="release"
export RELEASE_PATH
fi
nodeOS() {
osname=$OS
case $osname in
macos) osname=darwin ;;
windows) osname=win32 ;;
esac
echo "$osname"
}
nodeArch() {
cpu=$ARCH
case $cpu in
amd64) cpu=x64 ;;
esac
echo "$cpu"
}
# See gulpfile.reh.ts for available targets.
if [[ ! ${VSCODE_TARGET-} ]]; then
VSCODE_TARGET="$(nodeOS)-$(nodeArch)"
export VSCODE_TARGET
fi