Skip to content

Commit 977c579

Browse files
committed
feat: add update-vscode.sh script
1 parent 69ca92f commit 977c579

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

ci/dev/update-vscode.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
main() {
5+
cd "$(dirname "$0")/../.."
6+
7+
# Check if the remote exists
8+
# if it doesn't, we add it
9+
if ! git config remote.vscode.url > /dev/null; then
10+
echo "Could not find 'vscode' as a remote"
11+
echo "Adding with: git remote add -f vscode https://github.com/microsoft/vscode.git &> /dev/null"
12+
echo "Supressing output with '&> /dev/null'"
13+
git remote add -f vscode https://github.com/microsoft/vscode.git &> /dev/null
14+
fi
15+
16+
# Ask which version we should update to
17+
# In the future, we'll automate this and grab the latest version automatically
18+
read -p "What version of VSCode would you like to update to? (i.e. 1.52) " VSCODE_VERSION_TO_UPDATE
19+
20+
# Check that this version exists
21+
if [[ -z $(git ls-remote --heads vscode release/$VSCODE_VERSION_TO_UPDATE) ]]; then
22+
echo "Oops, that doesn't look like a valid version."
23+
echo "You entered: $VSCODE_VERSION_TO_UPDATE"
24+
echo "Verify that this branches exists here: https://github.com/microsoft/vscode/branches/all?query=release%2F$VSCODE_VERSION_TO_UPDATE"
25+
exit 1
26+
fi
27+
28+
echo -e "Great! We'll prep a PR for updating to $VSCODE_VERSION_TO_UPDATE\n"
29+
30+
# Check if GitHub CLI is installed
31+
if ! command -v gh &> /dev/null; then
32+
echo "GitHub CLI could not be found."
33+
echo "If you install it before you run this script next time, we'll open a draft PR for you!"
34+
echo -e "See docs here: https://github.com/cli/cli#installation\n"
35+
exit
36+
fi
37+
38+
# Push branch to remote if not already pushed
39+
# If we don't do this, the opening a draft PR step won't work
40+
# because it will stop and ask where you want to push the branch
41+
CURRENT_BRANCH=$(git branch --show-current)
42+
if [[ -z $(git ls-remote --heads origin $CURRENT_BRANCH) ]]; then
43+
echo "Doesn't look like you've pushed this branch to remote"
44+
echo -e "Pushing now using: git push origin $CURRENT_BRANCH\n"
45+
git push origin $CURRENT_BRANCH
46+
fi
47+
48+
echo "Opening a draft PR on GitHub"
49+
# To read about these flags, visit the docs: https://cli.github.com/manual/gh_pr_create
50+
gh pr create --base master --title "feat(vscode): update to version $VSCODE_VERSION_TO_UPDATE" --body "This PR updates `/lib/vscode` to version: $VSCODE_VERSION_TO_UPDATE" --reviewer @cdr/code-server-reviewers --repo cdr/code-server --draft
51+
52+
53+
echo "Going to try to update vscode for you..."
54+
echo -e "Running: git subtree pull --prefix lib/vscode vscode release/${VSCODE_VERSION_TO_UPDATE} --squash\n"
55+
# Try to run subtree update command
56+
git subtree pull --prefix lib/vscode vscode release/${VSCODE_VERSION_TO_UPDATE} --squash --message "chore(vscode): update to $VSCODE_VERSION_TO_UPDATE"
57+
}
58+
59+
main "$@"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"repository": "https://github.com/cdr/code-server",
1111
"scripts": {
1212
"clean": "./ci/build/clean.sh",
13-
"vscode:reset": "./ci/dev/reset-vscode.sh",
1413
"build": "./ci/build/build-code-server.sh",
1514
"build:vscode": "./ci/build/build-vscode.sh",
1615
"release": "./ci/build/build-release.sh",
@@ -20,6 +19,7 @@
2019
"test:standalone-release": "./ci/build/test-standalone-release.sh",
2120
"package": "./ci/build/build-packages.sh",
2221
"postinstall": "./ci/dev/postinstall.sh",
22+
"update:vscode": "./ci/dev/update-vscode.sh",
2323
"_____": "",
2424
"fmt": "./ci/dev/fmt.sh",
2525
"lint": "./ci/dev/lint.sh",

0 commit comments

Comments
 (0)