...

Text file src/google.golang.org/protobuf/release.bash

Documentation: google.golang.org/protobuf

     1#!/bin/bash
     2# Copyright 2019 The Go Authors. All rights reserved.
     3# Use of this source code is governed by a BSD-style
     4# license that can be found in the LICENSE file.
     5
     6cd "$(git rev-parse --show-toplevel)"
     7
     8read -p "What is the next release version (e.g., 'v1.26.0')?  " VERSION
     9SEMVER_REGEX='^v\([0-9]*\)[.]\([0-9]*\)[.]\([0-9]*\)\([.a-zA-Z0-9A-Z-]*\)$'
    10if ! [[ -z $(echo $VERSION | sed -e "s/$SEMVER_REGEX//") ]]; then
    11	echo; echo "invalid: must be a semver string"; exit 1
    12fi
    13VERSION_MAJOR=$(echo $VERSION | sed -e "s/$SEMVER_REGEX/\1/")
    14VERSION_MINOR=$(echo $VERSION | sed -e "s/$SEMVER_REGEX/\2/")
    15VERSION_PATCH=$(echo $VERSION | sed -e "s/$SEMVER_REGEX/\3/")
    16VERSION_PRERELEASE=$(echo $VERSION | sed -e "s/$SEMVER_REGEX/\4/")
    17if ! [[ "$VERSION_MAJOR" =~ ^1$ ]]; then
    18	echo; echo "invalid: major version must be 1"; exit 1
    19fi
    20if ! [[ -z $VERSION_PRERELEASE ]] && ! [[ "$VERSION_PRERELEASE" =~ ^-rc[.][0-9]+$ ]]; then
    21	echo; echo "invalid: pre-release suffix must be empty or '-rc.X'"; exit 1
    22fi
    23VERSION_PRERELEASE=${VERSION_PRERELEASE#"-"} # trim possible leading dash
    24
    25function version_string() {
    26	VERSION_STRING="v${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
    27	if ! [[ -z $VERSION_PRERELEASE ]]; then
    28		VERSION_STRING="${VERSION_STRING}-${VERSION_PRERELEASE}"
    29	fi
    30	echo $VERSION_STRING
    31}
    32
    33read -p "Were there any changes to the generator that relies on new runtime functionality?  " YN
    34case $YN in
    35[Yy]* )
    36	read -p "  What minor version of the runtime is required now?  " GEN_VERSION
    37	if ! [[ "$GEN_VERSION" =~ ^[0-9]+$ ]]; then echo; echo "invalid: must be an integer"; exit 1; fi;;
    38[Nn]* ) ;;
    39* ) echo; echo "invalid: must be 'yes' or 'no'"; exit 1;;
    40esac
    41
    42read -p "Were there any dropped functionality in the runtime for old generated code?  " YN
    43case $YN in
    44[Yy]* )
    45	read -p "  What minor version of the runtime is required now?  " MIN_VERSION
    46	if ! [[ "$MIN_VERSION" =~ ^[0-9]+$ ]]; then echo; echo "invalid: must be an integer"; exit 1; fi;;
    47[Nn]* ) ;;
    48* ) echo; echo "invalid: must be 'yes' or 'no'"; exit 1;;
    49esac
    50
    51
    52echo
    53echo "Preparing changes to release $(version_string)."
    54echo
    55
    56set -e
    57
    58# Create a new branch to contain the release changes.
    59if [[ $(git branch --list release) ]]; then
    60	echo "error: release branch already exists"; exit 1
    61fi
    62git codereview change release
    63git codereview sync
    64
    65# Create commit for actual release.
    66INPLACE='-i ""' # BSD version of sed expects argument after -i
    67if [[ "$(sed --version)" == *"GNU"* ]]; then
    68	INPLACE="-i" # GNU version of sed does not expect argument after -i
    69fi
    70sed $INPLACE -e "s/\(Minor *= *\)[0-9]*/\1$VERSION_MINOR/" internal/version/version.go
    71sed $INPLACE -e "s/\(Patch *= *\)[0-9]*/\1$VERSION_PATCH/" internal/version/version.go
    72sed $INPLACE -e "s/\(PreRelease *= *\)\"[^\"]*\"/\1\"$VERSION_PRERELEASE\"/" internal/version/version.go
    73if ! [[ -z $GEN_VERSION ]]; then
    74	sed $INPLACE -e "s/\(GenVersion *= *\)[0-9]*/\1$GEN_VERSION/" runtime/protoimpl/version.go
    75fi
    76if ! [[ -z $MIN_VERSION ]]; then
    77	sed $INPLACE -e "s/\(MinVersion *= *\)[0-9]*/\1$MIN_VERSION/" runtime/protoimpl/version.go
    78fi
    79git commit -a -m "all: release $(version_string)"
    80
    81# Build release binaries.
    82go test google.golang.org/protobuf -run='^TestIntegration$' -timeout=60m -count=1 "$@" -buildRelease
    83
    84# Create commit to start development after release.
    85VERSION_PRERELEASE="${VERSION_PRERELEASE}.devel" # append ".devel"
    86VERSION_PRERELEASE="${VERSION_PRERELEASE#"."}"   # trim possible leading "."
    87sed $INPLACE -e "s/\(PreRelease *= *\)\"[^\"]*\"/\1\"$VERSION_PRERELEASE\"/" internal/version/version.go
    88git commit -a -m "all: start $(version_string)"
    89
    90echo
    91echo "Release changes prepared. Additional steps:"
    92echo "  1) Submit the changes:"
    93echo "    a. Mail out the changes: git mail HEAD"
    94echo "    b. Request a review on the changes and merge them."
    95echo "  2) Tag a new release on GitHub:"
    96echo "    a. Write release notes highlighting notable changes."
    97echo "    b. Attach pre-compiled binaries as assets to the release."
    98echo

View as plain text