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