mirror of
https://github.com/coder/code-server.git
synced 2026-07-16 05:40:25 +02:00
Compare commits
2 Commits
62a552d896
...
1605d68709
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1605d68709 | ||
|
|
93ce398e28 |
2
.github/workflows/update.yaml
vendored
2
.github/workflows/update.yaml
vendored
@@ -7,7 +7,7 @@ on:
|
|||||||
type: string
|
type: string
|
||||||
required: true
|
required: true
|
||||||
schedule:
|
schedule:
|
||||||
- cron: "23 * * * *"
|
- cron: "0 16,21 * * *"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update:
|
update:
|
||||||
|
|||||||
@@ -2,13 +2,24 @@
|
|||||||
|
|
||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
|
|
||||||
function remove_patches() {
|
function quiet() {
|
||||||
|
"$@" >/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
function indent() {
|
||||||
|
local count=2
|
||||||
|
local space
|
||||||
|
space=$(printf "%${count}s")
|
||||||
|
sed "s/^/$space| /g"
|
||||||
|
}
|
||||||
|
|
||||||
|
function unapply_patches() {
|
||||||
local -i exit_code=0
|
local -i exit_code=0
|
||||||
quilt pop -af || exit_code=$?
|
quiet quilt pop -af || exit_code=$?
|
||||||
case $exit_code in
|
case $exit_code in
|
||||||
# Sucessfully removed.
|
# Sucessfully unapplied.
|
||||||
0) ;;
|
0) ;;
|
||||||
# No more patches to remove.
|
# No more patches to unapply.
|
||||||
2) ;;
|
2) ;;
|
||||||
# Some error.
|
# Some error.
|
||||||
*) return $exit_code ;;
|
*) return $exit_code ;;
|
||||||
@@ -17,7 +28,7 @@ function remove_patches() {
|
|||||||
|
|
||||||
function update_vscode() {
|
function update_vscode() {
|
||||||
pushd lib/vscode
|
pushd lib/vscode
|
||||||
if ! git checkout "$target_vscode_version" ; then
|
if ! git checkout 2>&1 "$target_vscode_version" ; then
|
||||||
echo "$target_vscode_version does not exist locally, fetching..."
|
echo "$target_vscode_version does not exist locally, fetching..."
|
||||||
git fetch --all --prune
|
git fetch --all --prune
|
||||||
git checkout "$target_vscode_version"
|
git checkout "$target_vscode_version"
|
||||||
@@ -27,9 +38,8 @@ function update_vscode() {
|
|||||||
|
|
||||||
function refresh_patches() {
|
function refresh_patches() {
|
||||||
local -i exit_code=0
|
local -i exit_code=0
|
||||||
while quilt push ; ! (( exit_code=$? )) ; do
|
while quiet quilt push ; ! (( exit_code=$? )) ; do
|
||||||
quilt refresh
|
quilt refresh
|
||||||
echo # Extra new line for separation.
|
|
||||||
done
|
done
|
||||||
case $exit_code in
|
case $exit_code in
|
||||||
# No more patches to apply.
|
# No more patches to apply.
|
||||||
@@ -43,7 +53,7 @@ function update_node() {
|
|||||||
local node_version
|
local node_version
|
||||||
node_version=$(cat .node-version)
|
node_version=$(cat .node-version)
|
||||||
if [[ $node_version == "$target_node_version" ]] ; then
|
if [[ $node_version == "$target_node_version" ]] ; then
|
||||||
echo "$node_version already matches $target_node_version"
|
echo "Already set to $target_node_version"
|
||||||
else
|
else
|
||||||
echo "Updating from $node_version to $target_node_version..."
|
echo "Updating from $node_version to $target_node_version..."
|
||||||
echo "$target_node_version" > .node-version
|
echo "$target_node_version" > .node-version
|
||||||
@@ -61,17 +71,28 @@ function get-webview-script-hash() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function update_csp() {
|
function update_csp() {
|
||||||
local -i exit_code=0
|
local current
|
||||||
# Move back to the webview patch so it can be refreshed.
|
current=$(quilt top 2>/dev/null || echo "")
|
||||||
quilt pop webview || exit_code=$?
|
local patch_action=""
|
||||||
case $exit_code in
|
echo "Currently at ${current:-base}"
|
||||||
# Successfully moved.
|
if [[ $current != */webview.diff ]] ; then
|
||||||
0) ;;
|
echo "Moving to patches/webview.diff..."
|
||||||
# Already at the patch.
|
local -i exit_code=0
|
||||||
2) ;;
|
if quilt applied 2>/dev/null | grep --quiet webview.diff ; then
|
||||||
# Some error.
|
quiet quilt pop webview || exit_code=$?
|
||||||
*) return $exit_code ;;
|
patch_action=pop
|
||||||
esac
|
else
|
||||||
|
quiet quilt push webview || exit_code=$?
|
||||||
|
patch_action=push
|
||||||
|
fi
|
||||||
|
case $exit_code in
|
||||||
|
# Successfully moved.
|
||||||
|
0) ;;
|
||||||
|
# Some error.
|
||||||
|
*) return $exit_code ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
local file=lib/vscode/src/vs/workbench/contrib/webview/browser/pre/index.html
|
local file=lib/vscode/src/vs/workbench/contrib/webview/browser/pre/index.html
|
||||||
local hash
|
local hash
|
||||||
hash=$(get-webview-script-hash "$file")
|
hash=$(get-webview-script-hash "$file")
|
||||||
@@ -79,8 +100,14 @@ function update_csp() {
|
|||||||
# Use octothorpe as a delimiter since the hash may contain a slash.
|
# Use octothorpe as a delimiter since the hash may contain a slash.
|
||||||
sed -i.bak "s#script-src 'sha256-[^']\+'#script-src 'sha256-$hash'#" "$file"
|
sed -i.bak "s#script-src 'sha256-[^']\+'#script-src 'sha256-$hash'#" "$file"
|
||||||
quilt refresh
|
quilt refresh
|
||||||
# Get patched back up.
|
|
||||||
quilt push -a
|
if [[ $patch_action != "" ]] ; then
|
||||||
|
echo "Moving back to ${current:-base}..."
|
||||||
|
case $patch_action in
|
||||||
|
pop) quiet quilt push "$current" ;;
|
||||||
|
push) quiet quilt pop "${current:--a}" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function run() {
|
function run() {
|
||||||
@@ -91,8 +118,8 @@ function run() {
|
|||||||
local fn=$1 ; shift
|
local fn=$1 ; shift
|
||||||
# Only run if an earlier step has not failed.
|
# Only run if an earlier step has not failed.
|
||||||
if [[ $failed == 0 ]] ; then
|
if [[ $failed == 0 ]] ; then
|
||||||
echo "[+] $name..."
|
echo "$name..."
|
||||||
if $fn ; then
|
if $fn | indent ; then
|
||||||
echo "- [X] $name" >> .cache/checklist
|
echo "- [X] $name" >> .cache/checklist
|
||||||
else
|
else
|
||||||
((failed++))
|
((failed++))
|
||||||
@@ -110,7 +137,7 @@ function run() {
|
|||||||
|
|
||||||
function add_changelog() {
|
function add_changelog() {
|
||||||
local file=CHANGELOG.md
|
local file=CHANGELOG.md
|
||||||
if grep "Code $target_vscode_version" "$file" ; then
|
if grep --quiet "Code $target_vscode_version" "$file" ; then
|
||||||
echo "Changelog for $target_vscode_version already exists"
|
echo "Changelog for $target_vscode_version already exists"
|
||||||
else
|
else
|
||||||
# TODO: This is not exactly robust. In particular, it needs to handle if
|
# TODO: This is not exactly robust. In particular, it needs to handle if
|
||||||
@@ -127,19 +154,28 @@ function main() {
|
|||||||
local target_node_version
|
local target_node_version
|
||||||
target_node_version=$(grep target lib/vscode/remote/.npmrc | awk -F= '{print $2}' | tr -d '"')
|
target_node_version=$(grep target lib/vscode/remote/.npmrc | awk -F= '{print $2}' | tr -d '"')
|
||||||
|
|
||||||
local target_vscode_version
|
|
||||||
target_vscode_version="${VERSION#v}"
|
|
||||||
|
|
||||||
declare -a steps
|
declare -a steps
|
||||||
# Removing patches only needs to be done locally; in CI we start from a fresh
|
|
||||||
# clone each time.
|
# If version is not set, assume we are already at the target version and the
|
||||||
if [[ ! ${CI-} ]] ; then
|
# user is just trying to resolve conflics.
|
||||||
steps+=("Remove patches" "remove_patches")
|
local target_vscode_version
|
||||||
|
if [[ ${VERSION-} ]] ; then
|
||||||
|
# Removing patches only needs to be done locally; in CI we start from a
|
||||||
|
# fresh clone each time.
|
||||||
|
if [[ ! ${CI-} ]] ; then
|
||||||
|
steps+=("Unapplying patches" "unapply_patches")
|
||||||
|
fi
|
||||||
|
target_vscode_version="${VERSION#v}"
|
||||||
|
steps+=(
|
||||||
|
"Update VS Code to $target_vscode_version" "update_vscode"
|
||||||
|
"Refresh VS Code patches" "refresh_patches"
|
||||||
|
)
|
||||||
|
else
|
||||||
|
target_vscode_version="$(git -C lib/vscode describe --tags --exact-match)"
|
||||||
|
echo "Detected VS Code version $target_vscode_version"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
steps+=(
|
steps+=(
|
||||||
"Update VS Code to $target_vscode_version" "update_vscode"
|
|
||||||
"Refresh VS Code patches" "refresh_patches"
|
|
||||||
"Set Node version to $target_node_version" "update_node"
|
"Set Node version to $target_node_version" "update_node"
|
||||||
"Update CSP webview hash" "update_csp"
|
"Update CSP webview hash" "update_csp"
|
||||||
"Add changelog note" "add_changelog"
|
"Add changelog note" "add_changelog"
|
||||||
|
|||||||
@@ -93,17 +93,20 @@ commits first if you are doing this).
|
|||||||
|
|
||||||
### Version updates to Code
|
### Version updates to Code
|
||||||
|
|
||||||
1. Remove any patches with `quilt pop -a`.
|
PRs will be automatically created with updates to VS Code. If a patch cannot be
|
||||||
2. Update the `lib/vscode` submodule to the desired upstream version branch.
|
automatically resolved, it will be necessary to clone the branch, resolve the
|
||||||
1. `cd lib/vscode && git checkout release/1.66 && cd ../..`
|
conflicts manually, and finish the update. To do this:
|
||||||
2. `git add lib && git commit -m "chore: update to Code <version>"`
|
|
||||||
3. Apply the patches one at a time (`quilt push`). If the application succeeds
|
1. Apply as many patches as possible `quilt push -a`.
|
||||||
but the lines changed, update the patch with `quilt refresh`. If there are
|
2. Once you hit a conflict, force apply with `quilt push -f`, manually add back
|
||||||
conflicts, then force apply with `quilt push -f`, manually add back the
|
the rejected code, then run `quilt refresh`.
|
||||||
rejected code, then run `quilt refresh`.
|
3. Once all patches have been resolved, run `./ci/build/update.sh` to finish the
|
||||||
4. From the code-server **project root**, run `npm install`.
|
update process.
|
||||||
5. Check the Node.js version that's used by Electron (which is shipped with VS
|
4. Commit all changes, push them up to the branch, and update the checklist in
|
||||||
Code. If necessary, update our version of Node.js to match.
|
the PR description.
|
||||||
|
|
||||||
|
Once the PR is ready, manually verify that the unreleased changelog section
|
||||||
|
contains all the changes going into this version before merging.
|
||||||
|
|
||||||
### Patching Code
|
### Patching Code
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user