|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +############################################################################## |
| 4 | +# RELEASING JAVA-OPERATOR-PLUGINS |
| 5 | +# |
| 6 | +# Every java-operator-plugins release should have a corresponding git |
| 7 | +# semantic version tag begining with `v`, for example: `v1.2.3`. |
| 8 | +# |
| 9 | +# STEP 1: Create a release branch with the name vX.Y.x. |
| 10 | +# For example: git checkout -b v1.2.x |
| 11 | +# |
| 12 | +# STEP 2: Run this release script by providing the java-operator-plugins |
| 13 | +# release version as an argument in the above mentioned format. |
| 14 | +# For example: ./release.sh vX.Y.Z |
| 15 | +# |
| 16 | +# STEP 3: This script will create a release tag locally. YOU, the releaser, |
| 17 | +# will push the release branch and tag: |
| 18 | +# |
| 19 | +# git push upstream <release-branch> |
| 20 | +# git push upstream <tag-name> |
| 21 | +# |
| 22 | +# where <tag-name> is the release version. |
| 23 | +# |
| 24 | +# STEP 4: Update the release notes in github with the changes included in |
| 25 | +# corresponding java-operator-plugins version. |
| 26 | +############################################################################## |
| 27 | + |
| 28 | +set -eu |
| 29 | + |
| 30 | +if [[ $# != 1 ]]; then |
| 31 | + echo "usage: $0 vX.Y.Z" |
| 32 | + exit 1 |
| 33 | +fi |
| 34 | + |
| 35 | +CUR_BRANCH=`git branch --show-current` |
| 36 | +VER=$1 |
| 37 | +NUMRE="0|[1-9][0-9]*" |
| 38 | +PRERE="\-(alpha|beta|rc)\.[1-9][0-9]*" |
| 39 | + |
| 40 | +# check that we are in a release branch |
| 41 | +if ! [[ "$CUR_BRANCH" =~ ^v($NUMRE)\.($NUMRE)\.($NUMRE)($PRERE)?$ ]]; then |
| 42 | + echo "branch: \"$CUR_BRANCH\" is not a release branch, please create a release branch in the form of vX.Y.x" |
| 43 | + exit 1 |
| 44 | +fi |
| 45 | + |
| 46 | +# verify the version format |
| 47 | +if ! [[ "$VER" =~ ^v($NUMRE)\.($NUMRE)\.($NUMRE)($PRERE)?$ ]]; then |
| 48 | + echo "malformed version: \"$VER\"" |
| 49 | + exit 1 |
| 50 | +fi |
| 51 | + |
| 52 | +# make sure we don't have anything uncommitted lying around |
| 53 | +if ! git diff-index --quiet HEAD --; then |
| 54 | + echo "directory has uncommitted files" |
| 55 | + exit 1 |
| 56 | +fi |
| 57 | + |
| 58 | +# run tests |
| 59 | +echo "Running tests" |
| 60 | +make lint test |
| 61 | + |
| 62 | +# tag the release commit and verify its tag |
| 63 | +echo "Creating a new tag for java-operator-plugins version $VER" |
| 64 | +git tag --sign --message "java-operator-plugins $VER" "$VER" |
| 65 | +git verify-tag --verbose $VER |
| 66 | + |
| 67 | +# remind the releaser to do the next steps |
| 68 | +echo "" |
| 69 | +echo "Don't forget to:" |
| 70 | +echo "" |
| 71 | +echo "git push upstream <release-branch>" |
| 72 | +echo "git push upstream $VER" |
| 73 | +echo "" |
| 74 | +echo "Also update the release notes in github for this tag." |
0 commit comments