-
Notifications
You must be signed in to change notification settings - Fork 5.9k
dev: add release:prep script #2952
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fa19f8c
feat: add release-prep script
jsjoeio a8858ea
docs(ci): update step 1 of publish release
jsjoeio a1dca6d
feat: add dry run option to release-prep.sh
jsjoeio 299e17e
refactor: update script command to get git branch
jsjoeio 305b820
Merge branch 'main' into jsjoeio/add-release-prep-script
repo-ranger[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
This PR is to generate a new release of `code-server` at `0.0.0` | ||
<!-- Note: this variable $CODE_SERVER_VERSION_TO_UPDATE will be set when you run the release-prep.sh script with `yarn release:prep` --> | ||
|
||
This PR is to generate a new release of `code-server` at `$CODE_SERVER_VERSION_TO_UPDATE` | ||
|
||
## Screenshot | ||
|
||
TODO | ||
|
||
## TODOs | ||
|
||
- [ ] update the AUR package | ||
- [ ] upload assets to draft release | ||
- [ ] test locally | ||
- [ ] upload assets to draft release | ||
- [ ] double-check github release tag is the commit with artifacts | ||
- [ ] publish release | ||
- [ ] merge PR | ||
- [ ] update the homebrew package | ||
- [ ] update the AUR package |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
#!/usr/bin/env bash | ||
# Description: This is a script to make the release process easier | ||
# Run it with `yarn release:prep` and it will do the following: | ||
# 1. Check that you have a $GITHUB_TOKEN set and hub installed | ||
# 2. Update the version of code-server (package.json, docs, etc.) | ||
# 3. Update the code coverage badge in the README | ||
# 4. Open a draft PR using the release_template.md and view in browser | ||
# If you want to perform a dry run of this script run DRY_RUN=1 yarn release:prep | ||
|
||
set -euo pipefail | ||
|
||
main() { | ||
if [ "${DRY_RUN-}" = 1 ]; then | ||
echo "Performing a dry run..." | ||
CMD="echo" | ||
else | ||
CMD='' | ||
fi | ||
|
||
cd "$(dirname "$0")/../.." | ||
|
||
# Check that $GITHUB_TOKEN is set | ||
if [[ -z ${GITHUB_TOKEN-} ]]; then | ||
echo "We couldn't find an environment variable under GITHUB_TOKEN." | ||
echo "This is needed for our scripts that use hub." | ||
echo -e "See docs regarding GITHUB_TOKEN here under 'GitHub OAuth authentication': https://hub.github.com/hub.1.html" | ||
exit | ||
fi | ||
|
||
# Check that hub is installed | ||
if ! command -v hub &>/dev/null; then | ||
echo "hub could not be found." | ||
echo "We use this with the release-github-draft.sh and release-github-assets.sh scripts." | ||
echo -e "See docs here: https://github.com/github/hub#installation" | ||
exit | ||
fi | ||
|
||
# Check that they have jq installed | ||
if ! command -v jq &>/dev/null; then | ||
echo "jq could not be found." | ||
echo "We use this to parse the package.json and grab the current version of code-server." | ||
echo -e "See docs here: https://stedolan.github.io/jq/download/" | ||
exit | ||
fi | ||
|
||
# Check that they have rg installed | ||
if ! command -v rg &>/dev/null; then | ||
echo "rg could not be found." | ||
echo "We use this when updating files across the codebase." | ||
echo -e "See docs here: https://github.com/BurntSushi/ripgrep#installation" | ||
exit | ||
fi | ||
|
||
# Check that they have sd installed | ||
if ! command -v sd &>/dev/null; then | ||
echo "sd could not be found." | ||
echo "We use this when updating files across the codebase." | ||
echo -e "See docs here: https://github.com/chmln/sd#installation" | ||
exit | ||
fi | ||
|
||
# Check that they have node installed | ||
if ! command -v node &>/dev/null; then | ||
echo "node could not be found." | ||
echo "That's surprising..." | ||
jsjoeio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
echo "We use it in this script for getting the package.json version" | ||
echo -e "See docs here: https://nodejs.org/en/download/" | ||
exit | ||
fi | ||
|
||
# credit to jakwuh for this solution | ||
# https://gist.github.com/DarrenN/8c6a5b969481725a4413#gistcomment-1971123 | ||
CODE_SERVER_CURRENT_VERSION=$(node -pe "require('./package.json').version") | ||
# Ask which version we should update to | ||
# In the future, we'll automate this and determine the latest version automatically | ||
echo "Current version: ${CODE_SERVER_CURRENT_VERSION}" | ||
# The $'\n' adds a line break. See: https://stackoverflow.com/a/39581815/3015595 | ||
read -r -p "What version of code-server do you want to update to?"$'\n' CODE_SERVER_VERSION_TO_UPDATE | ||
|
||
echo -e "Great! We'll prep a PR for updating to $CODE_SERVER_VERSION_TO_UPDATE\n" | ||
$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" | ||
|
||
# Ensure the tests are passing and code coverage is up-to-date | ||
echo -e "Running unit tests and updating code coverage...\n" | ||
$CMD yarn test:unit | ||
# Updates the Lines badge in the README | ||
$CMD yarn badges | ||
# Updates the svg to be green for the badge | ||
$CMD sd "red.svg" "green.svg" ../../README.md | ||
|
||
$CMD git commit -am "chore(release): bump version to $CODE_SERVER_VERSION_TO_UPDATE" | ||
|
||
# Note: we need to set upstream as well or the gh pr create step will fail | ||
# See: https://github.com/cli/cli/issues/575 | ||
CURRENT_BRANCH=$(git branch | grep '\*' | cut -d' ' -f2-) | ||
if [[ -z $(git config "branch.${CURRENT_BRANCH}.remote") ]]; then | ||
echo "Doesn't look like you've pushed this branch to remote" | ||
echo -e "Pushing now using: git push origin $CURRENT_BRANCH\n" | ||
# Note: we need to set upstream as well or the gh pr create step will fail | ||
# See: https://github.com/cli/cli/issues/575 | ||
echo "Please set the upstream and re-run the script" | ||
exit 1 | ||
fi | ||
|
||
# This runs from the root so that's why we use this path vs. ../../ | ||
RELEASE_TEMPLATE_STRING=$(cat ./.github/PULL_REQUEST_TEMPLATE/release_template.md) | ||
|
||
echo -e "\nOpening a draft PR on GitHub" | ||
# To read about these flags, visit the docs: https://cli.github.com/manual/gh_pr_create | ||
$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 | ||
|
||
# Open PR in browser | ||
$CMD gh pr view --web | ||
} | ||
|
||
main "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check for
gh
instead ofhub
hereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may be a noob at writing scripts but I'm not THAT much of a noob.
I know they're not the same tool 😂 That's intentional!
gh
ishub
's successor, hence why I'm using it here. Eventually, the plan is to remove the use ofhub
and only usegh
but now, the maintainer releasing should have both because it's used here and here.I'll make a follow-up issue to remove the use of
hub
and replace withgh
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#2960
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we check for
gh
elsewhere? I'm not too sure >.<There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in the
update-vscode
script too since it's used there.