Archived
1
0
This repository has been archived on 2024-09-09. You can view files and clone it, but cannot push or open issues or pull requests.
code-server/ci/dev/update-vscode.sh

69 lines
3.0 KiB
Bash
Raw Normal View History

2021-02-24 21:49:48 +01:00
#!/usr/bin/env bash
set -euo pipefail
main() {
cd "$(dirname "$0")/../.."
# Check if the remote exists
# if it doesn't, we add it
if ! git config remote.vscode.url > /dev/null; then
echo "Could not find 'vscode' as a remote"
echo "Adding with: git remote add vscode https://github.com/microsoft/vscode.git"
git remote add vscode https://github.com/microsoft/vscode.git
2021-02-24 21:49:48 +01:00
fi
# Ask which version we should update to
# In the future, we'll automate this and grab the latest version automatically
read -r -p "What version of VSCode would you like to update to? (i.e. 1.52) " VSCODE_VERSION_TO_UPDATE
2021-02-24 21:49:48 +01:00
# Check that this version exists
if [[ -z $(git ls-remote --heads vscode release/"$VSCODE_VERSION_TO_UPDATE") ]]; then
2021-02-24 21:49:48 +01:00
echo "Oops, that doesn't look like a valid version."
echo "You entered: $VSCODE_VERSION_TO_UPDATE"
echo "Verify that this branches exists here: https://github.com/microsoft/vscode/branches/all?query=release%2F$VSCODE_VERSION_TO_UPDATE"
exit 1
fi
# Check that they have jq installed
if ! command -v jq &> /dev/null; then
echo "jq could not be found."
echo "We use this when looking up the exact version to update to in the package.json in VS Code."
echo -e "See docs here: https://stedolan.github.io/jq/download/"
exit
fi
# Grab the exact version from package.json
VSCODE_EXACT_VERSION=$(curl -s "https://raw.githubusercontent.com/microsoft/vscode/release/$VSCODE_VERSION_TO_UPDATE/package.json" | jq -r ".version")
echo -e "Great! We'll prep a PR for updating to $VSCODE_EXACT_VERSION\n"
2021-02-24 21:49:48 +01:00
# Check if GitHub CLI is installed
if ! command -v gh &> /dev/null; then
2021-02-25 20:32:05 +01:00
echo "GitHub CLI could not be found."
echo "If you install it before you run this script next time, we'll open a draft PR for you!"
echo -e "See docs here: https://github.com/cli/cli#installation\n"
exit
2021-02-24 21:49:48 +01:00
fi
# Push branch to remote if not already pushed
# If we don't do this, the opening a draft PR step won't work
# because it will stop and ask where you want to push the branch
CURRENT_BRANCH=$(git branch --show-current)
if [[ -z $(git ls-remote --heads origin "$CURRENT_BRANCH") ]]; then
2021-02-24 21:49:48 +01:00
echo "Doesn't look like you've pushed this branch to remote"
echo -e "Pushing now using: git push origin $CURRENT_BRANCH\n"
git push origin "$CURRENT_BRANCH"
2021-02-24 21:49:48 +01:00
fi
echo "Opening a draft PR on GitHub"
# To read about these flags, visit the docs: https://cli.github.com/manual/gh_pr_create
gh pr create --base master --title "feat(vscode): update to version $VSCODE_EXACT_VERSION" --body "This PR updates vscode to version: $VSCODE_EXACT_VERSION" --reviewer @cdr/code-server-reviewers --repo cdr/code-server --draft
2021-02-24 21:49:48 +01:00
echo "Going to try to update vscode for you..."
echo -e "Running: git subtree pull --prefix lib/vscode vscode release/${VSCODE_VERSION_TO_UPDATE} --squash\n"
# Try to run subtree update command
git subtree pull --prefix lib/vscode vscode release/"${VSCODE_VERSION_TO_UPDATE}" --squash --message "chore(vscode): update to $VSCODE_VERSION_TO_UPDATE"
2021-02-24 21:49:48 +01:00
}
main "$@"