|
2 | 2 |
|
3 | 3 | set -e |
4 | 4 |
|
| 5 | +# For a given argument that is a release version, it will be the tag. For now, want the |
| 6 | +# format of `vX.Y.Z_A`. The underscore and `A` is important to include, as that is the |
| 7 | +# Famedly patch version that is separate from the upstream patch version |
5 | 8 | release_name=$1 |
6 | | -release_branch_name="release-${release_name%.*}" |
7 | | - |
8 | | -logical_cores=$([ $(uname) = 'Darwin' ] && |
9 | | - sysctl -n hw.logicalcpu_max || |
10 | | - nproc) |
11 | 9 |
|
12 | 10 | if [ -z "${release_name}" ]; then |
13 | | - echo "Usage: $0 <release_name>" |
| 11 | + echo "Usage: $0 <release_name in vX.Y.Z_A format>" |
14 | 12 | exit 1 |
15 | 13 | fi |
16 | 14 |
|
17 | 15 | if [ "${release_name}" = "-h" ]; then |
18 | | - echo "Usage: $0 <release_name>" |
| 16 | + echo "Usage: $0 <release_name in vX.Y.Z_A format>" |
19 | 17 | exit 0 |
20 | 18 | fi |
21 | 19 |
|
22 | | -git fetch --tags --multiple origin upstream |
23 | | -git checkout master |
24 | | -git reset --hard origin/master |
25 | | - |
26 | | -echo -e "\e[34m>>>> rebasing master branch\e[0m" |
27 | | -git rebase upstream/master |
28 | | -echo -e "\e[34m>>>> running lint and tests...\e[0m" |
29 | | -poetry install --extras all --no-interaction --remove-untracked |
30 | | -poetry run ./scripts-dev/lint.sh |
31 | | -poetry run trial -j"${logical_cores}" tests |
32 | | -echo -e "\e[34m>>>> Success!\e[0m" |
33 | | -git push -f |
34 | | - |
35 | | -echo -e "\e[34m>>>> updating release branch\e[0m" |
36 | | -git checkout -B "${release_branch_name}" |
37 | | -git merge --ff-only master |
38 | | -git push -f -u origin "${release_branch_name}" |
39 | | - |
40 | | -echo -e "\e[34m>>>> updating release tag\e[0m" |
41 | | -git checkout "${release_name}" |
42 | | -git merge --ff-only master |
43 | | -git tag -f -s -m "${release_name}_1" "${release_name}_1" |
44 | | -git push -f origin "${release_name}_1" |
| 20 | +# The major-minor number of the version, so of the release_name above which looks like `vX.Y.Z_A`, |
| 21 | +# we want the `vX.Y` |
| 22 | +release_major_minor=${release_name%.*} |
| 23 | + |
| 24 | +# What our branch name will be. Upstream uses the format of `release-vX.Y` so to avoid |
| 25 | +# confusion we will pre-pend 'famedly' to that and use a `/` to namespace it. Like this: |
| 26 | +# `famedly-release/vX.Y`. We do want patch levels and hotfixes to live on the same |
| 27 | +# branch as the release major.minor |
| 28 | +release_branch_name="famedly-release/${release_major_minor}" |
| 29 | + |
| 30 | +echo -e "\e[32m>>>> fetching origin branches\e[0m" |
| 31 | +# If the release_name that was passed already exists as a tag, this will fatal error. |
| 32 | +# Make sure it does not legitimately exist, or that you really mean to replace it before |
| 33 | +# running `git tag -d <release_name>` to remove that one single tag |
| 34 | +set +e |
| 35 | +if ! git fetch --tags origin; then |
| 36 | + echo "This tag appears to already exist, would you like to delete that tag so it can be forcibly replaced?" |
| 37 | + read -n 1 -p "Press y to delete, or any other key to exit ${\n}" input_key |
| 38 | + if [[ $input_key == "y"]]; then |
| 39 | + git tag -d $release_name |
| 40 | + else |
| 41 | + exit 1 |
| 42 | + fi |
| 43 | +fi |
| 44 | + |
| 45 | + |
| 46 | +set -e |
| 47 | +echo -e "\e[32m>>>> find/checkout release branch\e[0m" |
| 48 | +# Disable error catching for a moment, that we may tell the user a more explicit error |
| 49 | +# message than 'fatal' |
| 50 | +set +e |
| 51 | +if ! git switch "$release_branch_name"; then |
| 52 | + echo "The Famedly release branch for this version of Synapse seems to be missing. Was it already created?" |
| 53 | + exit 1 |
| 54 | +fi |
| 55 | +set -e |
| 56 | + |
| 57 | + |
| 58 | +read -n 1 -p "Press 'p' to push branch to Github, or any other key to skip\n" input_key |
| 59 | +if [[ $input_key == "p" ]]; then |
| 60 | + echo -e "\e[32m>>>> pushing release branch\e[0m" |
| 61 | + git push --force -u origin "${release_branch_name}" |
| 62 | +fi |
| 63 | + |
| 64 | +read -n 1 -p "Press 't' to run linting and tests, or any other key to skip\n" input_key |
| 65 | +if [[ $input_key == "t" ]]; then |
| 66 | + echo -e "\e[32m>>>> running lint and tests...\e[0m" |
| 67 | + # Make sure there are no weirdities around poetry. Until the deprecation migration |
| 68 | + # occurs, expect orange things to read here. |
| 69 | + poetry check |
| 70 | + poetry install --extras all --no-interaction |
| 71 | + poetry run ./scripts-dev/lint.sh |
| 72 | + |
| 73 | + logical_cores=$([ $(uname) = 'Darwin' ] && |
| 74 | + sysctl -n hw.logicalcpu_max || |
| 75 | + nproc) |
| 76 | + |
| 77 | + poetry run trial -j"${logical_cores}" tests |
| 78 | + echo -e "\e[32m>>>> Success!\e[0m" |
| 79 | +fi |
| 80 | + |
| 81 | +read -n 1 -p "Press 't' to create tag and push to Github, or any other key to skip\n" input_key |
| 82 | +if [[ $input_key == "t" ]]; then |
| 83 | + echo -e "\e[32m>>>> updating release tag\e[0m" |
| 84 | + git tag -f -s -m "${release_name}" "${release_name}" |
| 85 | + git push -f origin "${release_name}" |
| 86 | +fi |
| 87 | +echo -e "\e[32m>>>> Finished!\e[0m" |
0 commit comments