|
5 | 5 | # 2. Update the version of code-server (package.json, docs, etc.)
|
6 | 6 | # 3. Update the code coverage badge in the README
|
7 | 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=0 yarn release:prep |
8 | 9 |
|
9 | 10 | set -euo pipefail
|
10 | 11 |
|
11 | 12 | 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 | + |
12 | 20 | cd "$(dirname "$0")/../.."
|
13 | 21 |
|
14 | 22 | # Check that $GITHUB_TOKEN is set
|
@@ -73,31 +81,32 @@ main() {
|
73 | 81 | # I can't tell you why but
|
74 | 82 | # when searching with rg, the version needs to in this format: '3\.7\.5'
|
75 | 83 | # 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" |
77 | 85 |
|
78 | 86 | # Ensure the tests are passing and code coverage is up-to-date
|
79 | 87 | echo -e "Running unit tests and updating code coverage...\n"
|
80 |
| - yarn test:unit |
| 88 | + $CMD yarn test:unit |
81 | 89 | # Updates the Lines badge in the README
|
82 |
| - yarn badges |
| 90 | + $CMD yarn badges |
83 | 91 | # 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 |
85 | 93 |
|
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" |
87 | 95 |
|
88 | 96 | CURRENT_BRANCH=$(git branch --show-current)
|
89 | 97 | # Note: we need to set upstream as well or the gh pr create step will fail
|
90 | 98 | # See: https://github.com/cli/cli/issues/575
|
91 |
| - git push -u origin "$CURRENT_BRANCH" |
| 99 | + $CMD git push -u origin "$CURRENT_BRANCH" |
92 | 100 |
|
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) |
94 | 103 |
|
95 |
| - echo -e "Opening a draft PR on GitHub\n" |
| 104 | + echo -e "\nOpening a draft PR on GitHub" |
96 | 105 | # 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 |
98 | 107 |
|
99 | 108 | # Open PR in browser
|
100 |
| - gh pr view --web |
| 109 | + $CMD gh pr view --web |
101 | 110 | }
|
102 | 111 |
|
103 | 112 | main "$@"
|
0 commit comments