Skip to content

Commit 5a0a96f

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

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

ci/build/release-prep.sh

+19-10
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,18 @@
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+
CMD=echo
16+
else
17+
CMD=''
18+
fi
19+
1220
cd "$(dirname "$0")/../.."
1321

1422
# Check that $GITHUB_TOKEN is set
@@ -73,31 +81,32 @@ main() {
7381
# I can't tell you why but
7482
# when searching with rg, the version needs to in this format: '3\.7\.5'
7583
# 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"
84+
$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"
7785

7886
# Ensure the tests are passing and code coverage is up-to-date
7987
echo -e "Running unit tests and updating code coverage...\n"
80-
yarn test:unit
88+
$CMD yarn test:unit
8189
# Updates the Lines badge in the README
82-
yarn badges
90+
$CMD yarn badges
8391
# Updates the svg to be green for the badge
84-
sd "red.svg" "green.svg" ../../README.md
92+
$CMD sd "red.svg" "green.svg" ../../README.md
8593

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

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

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

95-
echo -e "Opening a draft PR on GitHub\n"
104+
echo -e "\nOpening a draft PR on GitHub"
96105
# 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
106+
$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
98107

99108
# Open PR in browser
100-
gh pr view --web
109+
$CMD gh pr view --web
101110
}
102111

103112
main "$@"

0 commit comments

Comments
 (0)