Skip to content

Commit 191cbe3

Browse files
committed
feat: add dry run option to release-prep.sh
1 parent b1b50f1 commit 191cbe3

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

ci/build/release-prep.sh

+24-10
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,23 @@
55
# 2. Update the version of code-server (package.json, docs, etc.)
66
# 3. Update the code coverage badge in the README
77
# 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=0 yarn release:prep
89

910
set -euo pipefail
1011

1112
main() {
13+
if [ "${DRY_RUN-1}" -eq 0 ]; then
14+
echo "Performing a dry run..."
15+
# Disabled because shellcheck wants me to do this
16+
# SC2209: Use var=$(command) to assign output (or quote to assign string).
17+
# But neither of those match my needs
18+
# We do this so that the dry run echos the commands instead of running them
19+
# shellcheck disable=SC2209
20+
CMD=echo
21+
else
22+
CMD=''
23+
fi
24+
1225
cd "$(dirname "$0")/../.."
1326

1427
# Check that $GITHUB_TOKEN is set
@@ -73,31 +86,32 @@ main() {
7386
# I can't tell you why but
7487
# when searching with rg, the version needs to in this format: '3\.7\.5'
7588
# that's why we have the parameter expansion with the regex
76-
rg -g '!yarn.lock' -g '!*.svg' --files-with-matches "${CODE_SERVER_CURRENT_VERSION//\./\\.}" | xargs sd "$CODE_SERVER_CURRENT_VERSION" "$CODE_SERVER_VERSION_TO_UPDATE"
89+
$CMD rg -g '!yarn.lock' -g '!*.svg' --files-with-matches "${CODE_SERVER_CURRENT_VERSION//\./\\.}" | $CMD xargs sd "$CODE_SERVER_CURRENT_VERSION" "$CODE_SERVER_VERSION_TO_UPDATE"
7790

7891
# Ensure the tests are passing and code coverage is up-to-date
7992
echo -e "Running unit tests and updating code coverage...\n"
80-
yarn test:unit
93+
$CMD yarn test:unit
8194
# Updates the Lines badge in the README
82-
yarn badges
95+
$CMD yarn badges
8396
# Updates the svg to be green for the badge
84-
sd "red.svg" "green.svg" ../../README.md
97+
$CMD sd "red.svg" "green.svg" ../../README.md
8598

86-
git add . && git commit -am "chore(release): bump version to $CODE_SERVER_VERSION_TO_UPDATE"
99+
$CMD git add . && $CMD git commit -am "chore(release): bump version to $CODE_SERVER_VERSION_TO_UPDATE"
87100

88101
CURRENT_BRANCH=$(git branch --show-current)
89102
# Note: we need to set upstream as well or the gh pr create step will fail
90103
# See: https://github.com/cli/cli/issues/575
91-
git push -u origin "$CURRENT_BRANCH"
104+
$CMD git push -u origin "$CURRENT_BRANCH"
92105

93-
RELEASE_TEMPLATE_STRING=$(cat ../../.github/PULL_REQUEST_TEMPLATE/release_template.md)
106+
# This runs from the root so that's why we use this path vs. ../../
107+
RELEASE_TEMPLATE_STRING=$(cat ./.github/PULL_REQUEST_TEMPLATE/release_template.md)
94108

95-
echo -e "Opening a draft PR on GitHub\n"
109+
echo -e "\nOpening a draft PR on GitHub"
96110
# To read about these flags, visit the docs: https://cli.github.com/manual/gh_pr_create
97-
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+
$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
98112

99113
# Open PR in browser
100-
gh pr view --web
114+
$CMD gh pr view --web
101115
}
102116

103117
main "$@"

0 commit comments

Comments
 (0)