github.com/michaelhenkel/operator-sdk@v0.8.1/release.sh (about) 1 #!/usr/bin/env bash 2 3 set -e 4 5 [ $# == 1 ] || { echo "usage: $0 version" && exit 1; } 6 7 VER=$1 8 9 [[ "$VER" =~ ^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$ ]] || { 10 echo "malformed version: \"$VER\"" 11 exit 2 12 } 13 14 if test -n "$(git ls-files --others | \ 15 grep --invert-match '\(vendor\|build/operator-sdk-v.\+\)')"; 16 then 17 echo "directory has untracked files" 18 exit 1 19 fi 20 21 if ! $(git diff-index --quiet HEAD --); then 22 echo "directory has uncommitted files" 23 exit 1 24 fi 25 26 GO_VER="1.12" 27 if ! go version | cut -d" " -f3 | grep -q "$GO_VER"; then 28 echo "must compile binaries with Go compiler version v${GO_VER}" 29 exit 1 30 fi 31 32 # Detect whether versions in code were updated. 33 VER_FILE="version/version.go" 34 CURR_VER="$(sed -nr 's|\s+Version\s+= "(.+)"|\1|p' "$VER_FILE" | tr -d ' \t\n')" 35 if [[ "$VER" != "$CURR_VER" ]]; then 36 echo "version is not set correctly in $VER_FILE" 37 exit 1 38 fi 39 40 GO_GOMOD="internal/pkg/scaffold/go_mod.go" 41 ANS_GOMOD="internal/pkg/scaffold/ansible/go_mod.go" 42 HELM_GOMOD="internal/pkg/scaffold/helm/go_mod.go" 43 CURR_VER_GO_GOMOD="$(sed -E -n -r 's|.*operator-sdk ([^ \t\n]+).*|\1|p' "$GO_GOMOD" | tail -1 | tr -d ' \t\n')" 44 if [[ "$VER" != "$CURR_VER_GO_GOMOD" ]]; then 45 echo "go.mod 'replace' entry version is not set correctly in $GO_GOMOD" 46 exit 1 47 fi 48 CURR_VER_ANS_GOMOD="$(sed -E -n -r 's|.*operator-sdk ([^ \t\n]+).*|\1|p' "$ANS_GOMOD" | tail -1 | tr -d ' \t\n')" 49 if [[ "$VER" != "$CURR_VER_ANS_GOMOD" ]]; then 50 echo "go.mod 'replace' entry version is not set correctly in $ANS_GOMOD" 51 exit 1 52 fi 53 CURR_VER_HELM_GOMOD="$(sed -E -n -r 's|.*operator-sdk ([^ \t\n]+).*|\1|p' "$HELM_GOMOD" | tail -1 | tr -d ' \t\n')" 54 if [[ "$VER" != "$CURR_VER_HELM_GOMOD" ]]; then 55 echo "go.mod 'replace' entry version is not set correctly in $HELM_GOMOD" 56 exit 1 57 fi 58 59 GO_DEP="internal/pkg/scaffold/gopkgtoml.go" 60 ANS_DEP="internal/pkg/scaffold/ansible/gopkgtoml.go" 61 HELM_DEP="internal/pkg/scaffold/helm/gopkgtoml.go" 62 INSTALL_GUIDE_FILE="doc/user/install-operator-sdk.md" 63 CURR_VER_GO_DEP="$(sed -nr 's/.*".*v(.+)".*#osdk_version_annotation/v\1/p' "$GO_DEP" | tr -d ' \t\n')" 64 if [[ "$VER" != "$CURR_VER_GO_DEP" ]]; then 65 echo "Gopkg.toml 'constraint' version is not set correctly in $GO_DEP" 66 exit 1 67 fi 68 CURR_VER_ANS_DEP="$(sed -nr 's/.*".*v(.+)".*#osdk_version_annotation/v\1/p' "$ANS_DEP" | tr -d ' \t\n')" 69 if [[ "$VER" != "$CURR_VER_ANS_DEP" ]]; then 70 echo "Gopkg.toml 'constraint' version is not set correctly in $ANS_DEP" 71 exit 1 72 fi 73 74 CURR_VER_HELM_DEP="$(sed -nr 's/.*".*v(.+)".*#osdk_version_annotation/v\1/p' "$HELM_DEP" | tr -d ' \t\n')" 75 if [[ "$VER" != "$CURR_VER_HELM_DEP" ]]; then 76 echo "Gopkg.toml 'constraint' version is not set correctly in $HELM_DEP" 77 exit 1 78 fi 79 80 CURR_VER_INSTALL_GUIDE_FILE="$(sed -nr 's/RELEASE_VERSION=(.+)/\1/p' "$INSTALL_GUIDE_FILE" | tr -d ' \t\n')" 81 if [[ "$VER" != "$CURR_VER_INSTALL_GUIDE_FILE" ]]; then 82 echo "version '$VER' is not set correctly in $INSTALL_GUIDE_FILE" 83 exit 1 84 fi 85 git tag --sign --message "Operator SDK $VER" "$VER" 86 87 git verify-tag --verbose "$VER" 88 89 make release