Skip to content

Commit 004c608

Browse files
Merge pull request #2952 from cdr/jsjoeio/add-release-prep-script
dev: add release:prep script
2 parents 8332a6a + 305b820 commit 004c608

File tree

5 files changed

+127
-18
lines changed

5 files changed

+127
-18
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
This PR is to generate a new release of `code-server` at `0.0.0`
1+
<!-- Note: this variable $CODE_SERVER_VERSION_TO_UPDATE will be set when you run the release-prep.sh script with `yarn release:prep` -->
2+
3+
This PR is to generate a new release of `code-server` at `$CODE_SERVER_VERSION_TO_UPDATE`
24

35
## Screenshot
46

57
TODO
68

79
## TODOs
810

9-
- [ ] update the AUR package
10-
- [ ] upload assets to draft release
1111
- [ ] test locally
12+
- [ ] upload assets to draft release
1213
- [ ] double-check github release tag is the commit with artifacts
1314
- [ ] publish release
1415
- [ ] merge PR
1516
- [ ] update the homebrew package
17+
- [ ] update the AUR package

ci/README.md

+1-12
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,7 @@ Any file or directory in this subdirectory should be documented here.
1212

1313
## Publishing a release
1414

15-
Make sure you have `$GITHUB_TOKEN` set and [hub](https://github.com/github/hub) installed.
16-
17-
1. Update the version of code-server and make a PR.
18-
1. Update in `package.json`
19-
2. Update in [./docs/install.md](../docs/install.md)
20-
3. Update in [./ci/helm-chart/README.md](../ci/helm-chart/README.md)
21-
- Remember to update the chart version as well on top of appVersion in `Chart.yaml`.
22-
- Run `rg -g '!yarn.lock' -g '!*.svg' '3\.7\.5'` to ensure all values have been
23-
changed. Replace the numbers as needed.
24-
- You can install `rg` or `ripgrep` on macOS [here](https://formulae.brew.sh/formula/ripgrep).
25-
4. Update the code coverage badge (see [here](#updating-code-coverage-in-readme) for instructions)
26-
5. Update the docs badge in [./README.md](../README.md)
15+
1. Run `yarn release:prep` and type in the new version i.e. 3.8.1
2716
2. GitHub actions will generate the `npm-package`, `release-packages` and `release-images` artifacts.
2817
1. You do not have to wait for these.
2918
3. Run `yarn release:github-draft` to create a GitHub draft release from the template with

ci/build/release-prep.sh

+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#!/usr/bin/env bash
2+
# Description: This is a script to make the release process easier
3+
# Run it with `yarn release:prep` and it will do the following:
4+
# 1. Check that you have a $GITHUB_TOKEN set and hub installed
5+
# 2. Update the version of code-server (package.json, docs, etc.)
6+
# 3. Update the code coverage badge in the README
7+
# 4. Open a draft PR using the release_template.md and view in browser
8+
# If you want to perform a dry run of this script run DRY_RUN=1 yarn release:prep
9+
10+
set -euo pipefail
11+
12+
main() {
13+
if [ "${DRY_RUN-}" = 1 ]; then
14+
echo "Performing a dry run..."
15+
CMD="echo"
16+
else
17+
CMD=''
18+
fi
19+
20+
cd "$(dirname "$0")/../.."
21+
22+
# Check that $GITHUB_TOKEN is set
23+
if [[ -z ${GITHUB_TOKEN-} ]]; then
24+
echo "We couldn't find an environment variable under GITHUB_TOKEN."
25+
echo "This is needed for our scripts that use hub."
26+
echo -e "See docs regarding GITHUB_TOKEN here under 'GitHub OAuth authentication': https://hub.github.com/hub.1.html"
27+
exit
28+
fi
29+
30+
# Check that hub is installed
31+
if ! command -v hub &>/dev/null; then
32+
echo "hub could not be found."
33+
echo "We use this with the release-github-draft.sh and release-github-assets.sh scripts."
34+
echo -e "See docs here: https://github.com/github/hub#installation"
35+
exit
36+
fi
37+
38+
# Check that they have jq installed
39+
if ! command -v jq &>/dev/null; then
40+
echo "jq could not be found."
41+
echo "We use this to parse the package.json and grab the current version of code-server."
42+
echo -e "See docs here: https://stedolan.github.io/jq/download/"
43+
exit
44+
fi
45+
46+
# Check that they have rg installed
47+
if ! command -v rg &>/dev/null; then
48+
echo "rg could not be found."
49+
echo "We use this when updating files across the codebase."
50+
echo -e "See docs here: https://github.com/BurntSushi/ripgrep#installation"
51+
exit
52+
fi
53+
54+
# Check that they have sd installed
55+
if ! command -v sd &>/dev/null; then
56+
echo "sd could not be found."
57+
echo "We use this when updating files across the codebase."
58+
echo -e "See docs here: https://github.com/chmln/sd#installation"
59+
exit
60+
fi
61+
62+
# Check that they have node installed
63+
if ! command -v node &>/dev/null; then
64+
echo "node could not be found."
65+
echo "That's surprising..."
66+
echo "We use it in this script for getting the package.json version"
67+
echo -e "See docs here: https://nodejs.org/en/download/"
68+
exit
69+
fi
70+
71+
# credit to jakwuh for this solution
72+
# https://gist.github.com/DarrenN/8c6a5b969481725a4413#gistcomment-1971123
73+
CODE_SERVER_CURRENT_VERSION=$(node -pe "require('./package.json').version")
74+
# Ask which version we should update to
75+
# In the future, we'll automate this and determine the latest version automatically
76+
echo "Current version: ${CODE_SERVER_CURRENT_VERSION}"
77+
# The $'\n' adds a line break. See: https://stackoverflow.com/a/39581815/3015595
78+
read -r -p "What version of code-server do you want to update to?"$'\n' CODE_SERVER_VERSION_TO_UPDATE
79+
80+
echo -e "Great! We'll prep a PR for updating to $CODE_SERVER_VERSION_TO_UPDATE\n"
81+
$CMD rg -g '!yarn.lock' -g '!*.svg' --files-with-matches --fixed-strings "${CODE_SERVER_CURRENT_VERSION}" | $CMD xargs sd "$CODE_SERVER_CURRENT_VERSION" "$CODE_SERVER_VERSION_TO_UPDATE"
82+
83+
# Ensure the tests are passing and code coverage is up-to-date
84+
echo -e "Running unit tests and updating code coverage...\n"
85+
$CMD yarn test:unit
86+
# Updates the Lines badge in the README
87+
$CMD yarn badges
88+
# Updates the svg to be green for the badge
89+
$CMD sd "red.svg" "green.svg" ../../README.md
90+
91+
$CMD git commit -am "chore(release): bump version to $CODE_SERVER_VERSION_TO_UPDATE"
92+
93+
# Note: we need to set upstream as well or the gh pr create step will fail
94+
# See: https://github.com/cli/cli/issues/575
95+
CURRENT_BRANCH=$(git branch | grep '\*' | cut -d' ' -f2-)
96+
if [[ -z $(git config "branch.${CURRENT_BRANCH}.remote") ]]; then
97+
echo "Doesn't look like you've pushed this branch to remote"
98+
echo -e "Pushing now using: git push origin $CURRENT_BRANCH\n"
99+
# Note: we need to set upstream as well or the gh pr create step will fail
100+
# See: https://github.com/cli/cli/issues/575
101+
echo "Please set the upstream and re-run the script"
102+
exit 1
103+
fi
104+
105+
# This runs from the root so that's why we use this path vs. ../../
106+
RELEASE_TEMPLATE_STRING=$(cat ./.github/PULL_REQUEST_TEMPLATE/release_template.md)
107+
108+
echo -e "\nOpening a draft PR on GitHub"
109+
# To read about these flags, visit the docs: https://cli.github.com/manual/gh_pr_create
110+
$CMD gh pr create --base main --title "release: $CODE_SERVER_VERSION_TO_UPDATE" --body "$RELEASE_TEMPLATE_STRING" --reviewer @cdr/code-server-reviewers --repo cdr/code-server --draft
111+
112+
# Open PR in browser
113+
$CMD gh pr view --web
114+
}
115+
116+
main "$@"

ci/dev/update-vscode.sh

+4-3
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,14 @@ main() {
8181
# Push branch to remote if not already pushed
8282
# If we don't do this, the opening a draft PR step won't work
8383
# because it will stop and ask where you want to push the branch
84-
CURRENT_BRANCH=$(git branch --show-current)
85-
if [[ -z $(git ls-remote --heads origin "$CURRENT_BRANCH") ]]; then
84+
CURRENT_BRANCH=$(git branch | grep '\*' | cut -d' ' -f2-)
85+
if [[ -z $(git config "branch.${CURRENT_BRANCH}.remote") ]]; then
8686
echo "Doesn't look like you've pushed this branch to remote"
8787
echo -e "Pushing now using: git push origin $CURRENT_BRANCH\n"
8888
# Note: we need to set upstream as well or the gh pr create step will fail
8989
# See: https://github.com/cli/cli/issues/575
90-
git push -u origin "$CURRENT_BRANCH"
90+
echo "Please set the upstream and re-run the script"
91+
exit 1
9192
fi
9293

9394
echo "Going to try to update vscode for you..."

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"release:standalone": "./ci/build/build-standalone-release.sh",
1717
"release:github-draft": "./ci/build/release-github-draft.sh",
1818
"release:github-assets": "./ci/build/release-github-assets.sh",
19+
"release:prep": "./ci/build/release-prep.sh",
1920
"test:e2e": "./ci/dev/test-e2e.sh",
2021
"test:standalone-release": "./ci/build/test-standalone-release.sh",
2122
"test:unit": "./ci/dev/test-unit.sh",

0 commit comments

Comments
 (0)