diff --git a/client/v2/go.mod b/client/v2/go.mod index 4c9a6ec9534..0c12a87aacb 100644 --- a/client/v2/go.mod +++ b/client/v2/go.mod @@ -5,8 +5,8 @@ go 1.15 require ( github.com/json-iterator/go v1.1.10 github.com/modern-go/reflect2 v1.0.1 - go.etcd.io/etcd/api/v3 v3.0.0-00010101000000-000000000000 - go.etcd.io/etcd/pkg/v3 v3.0.0-00010101000000-000000000000 + go.etcd.io/etcd/api/v3 v3.5.0-pre + go.etcd.io/etcd/pkg/v3 v3.5.0-pre ) replace ( diff --git a/client/v3/go.mod b/client/v3/go.mod index ffa8ec18f5c..928c335d7f4 100644 --- a/client/v3/go.mod +++ b/client/v3/go.mod @@ -7,8 +7,8 @@ require ( github.com/google/uuid v1.1.2 github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 github.com/prometheus/client_golang v1.5.1 - go.etcd.io/etcd/api/v3 v3.0.0-00010101000000-000000000000 - go.etcd.io/etcd/pkg/v3 v3.0.0-00010101000000-000000000000 + go.etcd.io/etcd/api/v3 v3.5.0-pre + go.etcd.io/etcd/pkg/v3 v3.5.0-pre go.uber.org/zap v1.16.0 google.golang.org/grpc v1.29.1 sigs.k8s.io/yaml v1.2.0 diff --git a/etcdctl/go.mod b/etcdctl/go.mod index 519e6be7f0e..b0aebdbff05 100644 --- a/etcdctl/go.mod +++ b/etcdctl/go.mod @@ -11,12 +11,12 @@ require ( github.com/spf13/pflag v1.0.5 github.com/urfave/cli v1.22.4 go.etcd.io/bbolt v1.3.5 - go.etcd.io/etcd/api/v3 v3.0.0-00010101000000-000000000000 - go.etcd.io/etcd/client/v2 v2.0.0-00010101000000-000000000000 - go.etcd.io/etcd/client/v3 v3.0.0-00010101000000-000000000000 - go.etcd.io/etcd/pkg/v3 v3.0.0-00010101000000-000000000000 - go.etcd.io/etcd/raft/v3 v3.0.0-00010101000000-000000000000 - go.etcd.io/etcd/server/v3 v3.0.0-00010101000000-000000000000 + go.etcd.io/etcd/api/v3 v3.5.0-pre + go.etcd.io/etcd/client/v2 v2.305.0-pre + go.etcd.io/etcd/client/v3 v3.5.0-pre + go.etcd.io/etcd/pkg/v3 v3.5.0-pre + go.etcd.io/etcd/raft/v3 v3.5.0-pre + go.etcd.io/etcd/server/v3 v3.5.0-pre go.uber.org/zap v1.16.0 golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e google.golang.org/grpc v1.29.1 diff --git a/go.mod b/go.mod index 2fd43f53dba..a41d019e788 100644 --- a/go.mod +++ b/go.mod @@ -19,13 +19,13 @@ require ( github.com/mattn/go-runewidth v0.0.9 // indirect github.com/spf13/cobra v1.1.1 go.etcd.io/bbolt v1.3.5 - go.etcd.io/etcd/api/v3 v3.0.0-00010101000000-000000000000 - go.etcd.io/etcd/client/v2 v2.0.0-00010101000000-000000000000 - go.etcd.io/etcd/client/v3 v3.0.0-00010101000000-000000000000 - go.etcd.io/etcd/pkg/v3 v3.0.0-00010101000000-000000000000 - go.etcd.io/etcd/raft/v3 v3.0.0-00010101000000-000000000000 - go.etcd.io/etcd/server/v3 v3.0.0-00010101000000-000000000000 - go.etcd.io/etcd/tests/v3 v3.0.0-00010101000000-000000000000 + go.etcd.io/etcd/api/v3 v3.5.0-pre + go.etcd.io/etcd/client/v2 v2.305.0-pre + go.etcd.io/etcd/client/v3 v3.5.0-pre + go.etcd.io/etcd/pkg/v3 v3.5.0-pre + go.etcd.io/etcd/raft/v3 v3.5.0-pre + go.etcd.io/etcd/server/v3 v3.5.0-pre + go.etcd.io/etcd/tests/v3 v3.5.0-pre go.uber.org/zap v1.16.0 golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e google.golang.org/grpc v1.29.1 diff --git a/raft/go.mod b/raft/go.mod index c594d30e918..cb9ca17f22c 100644 --- a/raft/go.mod +++ b/raft/go.mod @@ -7,7 +7,7 @@ require ( github.com/gogo/protobuf v1.3.1 github.com/golang/protobuf v1.3.5 github.com/pkg/errors v0.9.1 // indirect - go.etcd.io/etcd/pkg/v3 v3.0.0-00010101000000-000000000000 + go.etcd.io/etcd/pkg/v3 v3.5.0-pre ) // Bad imports are sometimes causing attempts to pull that code. diff --git a/scripts/release_mod.sh b/scripts/release_mod.sh new file mode 100755 index 00000000000..21afdb0dfa8 --- /dev/null +++ b/scripts/release_mod.sh @@ -0,0 +1,124 @@ +#!/usr/bin/env bash + +# Examples: + +# Edit go.mod files such that all etcd modules are pointing on given version: +# +# % DRY_RUN=false TARGET_VERSION="v3.5.13" ./scripts/release_mod.sh update_versions + +# Tag latest commit with current version number for all the modules and push upstream: +# +# % DRY_RUN=false REMOTE_REPO="origin" ./scripts/release_mod.sh push_mod_tags + +set -e + +DRY_RUN=${DRY_RUN:-true} + +if ! [[ "$0" =~ scripts/release_mod.sh ]]; then + echo "must be run from repository root" + exit 255 +fi + +source ./scripts/test_lib.sh + +# _cmd prints help message +function _cmd() { + log_error "Command required: ${0} [cmd]" + log_info "Available commands:" + log_info " - update_versions - Updates all cross-module versions to \${TARGET_VERSION} in the local client." + log_info " - push_mod_tags - Tags HEAD with all modules versions tags and pushes it to \${REMOTE_REPO}." +} + +# maybe_run [cmd...] runs given command depending on the DRY_RUN flag. +function maybe_run() { + if ${DRY_RUN}; then + log_warning -e "# DRY_RUN:\n % ${*}" + else + run "${@}" + fi +} + +# update_module_version [v2version] [v3version] +# Updates versions of cross-references in all internal references in current module. +function update_module_version() { + local v3version="${1}" + local v2version="${2}" + local modules + modules=$(run go list -f '{{if not .Main}}{{if not .Indirect}}{{.Path}}{{end}}{{end}}' -m all) + + v3deps=$(echo "${modules}" | grep -E "${REPO}/.*/v3") + for dep in ${v3deps}; do + maybe_run go mod edit -require "${dep}@${v3version}" + done + + v2deps=$(echo "${modules}" | grep -E "${REPO}/.*/v2") + for dep in ${v2deps}; do + maybe_run go mod edit -require "${dep}@${v2version}" + done +} + +# Updates all cross-module versions to ${TARGET_VERSION} in local client. +function update_versions_cmd() { + assert_no_git_modifications || return 2 + + if [ -z "${TARGET_VERSION}" ]; then + log_error "TARGET_VERSION environment variable not set. Set it to e.g. v3.5.10-alpha.0" + return 2 + fi + + local v3version="${TARGET_VERSION}" + local v2version + # converts e.g. v3.5.0-alpha.0 --> v2.305.0-alpha.0 + # shellcheck disable=SC2001 + v2version="$(echo "${TARGET_VERSION}" | sed 's|^v3.\([0-9]*\).|v2.30\1.|g')" + + log_info "DRY_RUN : ${DRY_RUN}" + log_info "TARGET_VERSION: ${TARGET_VERSION}" + log_info "" + log_info "v3version: ${v3version}" + log_info "v2version: ${v2version}" + + run_for_modules update_module_version "${v3version}" "${v2version}" +} + +function push_mod_tags_cmd { + assert_no_git_modifications || return 2 + + if [ -z "${REMOTE_REPO}" ]; then + log_error "REMOTE_REPO environment variable not set" + return 2 + fi + log_info "REMOTE_REPO: ${REMOTE_REPO}" + + # Any module ccan be used for this + local master_version + master_version=$(go list -f '{{.Version}}' -m "${REPO}/api/v3") + local tags=() + + for module in $(modules); do + local version + version=$(go list -f '{{.Version}}' -m "${module}") + local path + path=$(go list -f '{{.Path}}' -m "${module}") + local subdir="${path//${REPO}\//}" + local tag + if [ -z "${version}" ]; then + tag="${master_version}" + version="${master_version}" + else + tag="${subdir///v[23]/}/${version}" + fi + + log_info "Tags for: ${module} version:${version} tag:${tag}" + maybe_run git tag -f "${tag}" + tags=("${tags[@]}" "${tag}") + done + maybe_run git push -f "${REMOTE_REPO}" "${tags[@]}" +} + +"${1}_cmd" + +if "${DRY_RUN}"; then + log_info + log_warning "WARNING: It was a DRY_RUN. No files were modified." +fi diff --git a/scripts/test_lib.sh b/scripts/test_lib.sh index 9769de9c544..ec2045d7d29 100644 --- a/scripts/test_lib.sh +++ b/scripts/test_lib.sh @@ -1,11 +1,13 @@ #!/usr/bin/env bash -if [[ "$(go list)" != "go.etcd.io/etcd/v3" ]]; then - echo "must be run from 'go.etcd.io/etcd/v3' module directory" +REPO="go.etcd.io/etcd" + +if [[ "$(go list)" != "${REPO}/v3" ]]; then + echo "must be run from '${REPO}/v3' module directory" exit 255 fi -ETCD_ROOT_DIR=$(go list -f '{{.Dir}}' "go.etcd.io/etcd/v3") +ETCD_ROOT_DIR=$(go list -f '{{.Dir}}' "${REPO}/v3") #### Convenient IO methods ##### @@ -48,6 +50,12 @@ function log_success { >&2 echo -n -e "${COLOR_NONE}" } +function log_info { + >&2 echo -n -e "${COLOR_NONE}" + >&2 echo "$@" + >&2 echo -n -e "${COLOR_NONE}" +} + # From http://stackoverflow.com/a/12498485 function relativePath { # both $1 and $2 are absolute paths beginning with / @@ -105,6 +113,11 @@ function pkgs_in_module { go list -mod=mod "${1:-./...}"; } +# Prints subdirectory (from the repo root) for the current module. +function module_subdir { + relativePath "${ETCD_ROOT_DIR}" "${PWD}" +} + #### Running actions against multiple modules #### # run [command...] - runs given command, printing it first and @@ -114,11 +127,11 @@ function pkgs_in_module { function run { local rpath local command - rpath=$(relativePath "${ETCD_ROOT_DIR}" "${PWD}") + rpath=$(module_subdir) # Quoting all components as the commands are fully copy-parsable: command=("${@}") command=("${command[@]@Q}") - if [ "${rpath}" != "." ]; then + if [[ "${rpath}" != "." && "${rpath}" != "" ]]; then repro="(cd ${rpath} && ${command[*]})" else repro="${command[*]}" @@ -147,15 +160,15 @@ function run_for_module { function modules() { modules=( - go.etcd.io/etcd/api/v3 - go.etcd.io/etcd/pkg/v3 - go.etcd.io/etcd/raft/v3 - go.etcd.io/etcd/client/v2 - go.etcd.io/etcd/client/v3 - go.etcd.io/etcd/server/v3 - go.etcd.io/etcd/etcdctl/v3 - go.etcd.io/etcd/tests/v3 - go.etcd.io/etcd/v3) + "${REPO}/api/v3" + "${REPO}/pkg/v3" + "${REPO}/raft/v3" + "${REPO}/client/v2" + "${REPO}/client/v3" + "${REPO}/server/v3" + "${REPO}/etcdctl/v3" + "${REPO}/tests/v3" + "${REPO}/v3") echo "${modules[@]}" } @@ -313,3 +326,16 @@ function run_go_tool { run "${cmdbin}" "$@" || return 2 } +# assert_no_git_modifications fails if there are any uncommited changes. +function assert_no_git_modifications { + log_callout "Making sure everything is committed." + if ! git diff --cached --exit-code; then + log_error "Found staged by uncommited changes. Do commit/stash your changes first." + return 2 + fi + if ! git diff --exit-code; then + log_error "Found unstaged and uncommited changes. Do commit/stash your changes first." + return 2 + fi +} + diff --git a/server/go.mod b/server/go.mod index 91c2dca97cf..0fa5edc49c6 100644 --- a/server/go.mod +++ b/server/go.mod @@ -27,11 +27,11 @@ require ( github.com/tmc/grpc-websocket-proxy v0.0.0-20200427203606-3cfed13b9966 github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 go.etcd.io/bbolt v1.3.5 - go.etcd.io/etcd/api/v3 v3.0.0-00010101000000-000000000000 - go.etcd.io/etcd/client/v2 v2.0.0-00010101000000-000000000000 - go.etcd.io/etcd/client/v3 v3.0.0-00010101000000-000000000000 - go.etcd.io/etcd/pkg/v3 v3.0.0-00010101000000-000000000000 - go.etcd.io/etcd/raft/v3 v3.0.0-00010101000000-000000000000 + go.etcd.io/etcd/api/v3 v3.5.0-pre + go.etcd.io/etcd/client/v2 v2.305.0-pre + go.etcd.io/etcd/client/v3 v3.5.0-pre + go.etcd.io/etcd/pkg/v3 v3.5.0-pre + go.etcd.io/etcd/raft/v3 v3.5.0-pre go.uber.org/zap v1.16.0 golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0 golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect diff --git a/tests/go.mod b/tests/go.mod index 85a2bf01d61..61a64ac9c33 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -25,13 +25,13 @@ require ( github.com/spf13/cobra v1.1.1 github.com/spf13/pflag v1.0.5 go.etcd.io/bbolt v1.3.5 - go.etcd.io/etcd/api/v3 v3.0.0-00010101000000-000000000000 - go.etcd.io/etcd/client/v2 v2.0.0-00010101000000-000000000000 - go.etcd.io/etcd/client/v3 v3.0.0-00010101000000-000000000000 - go.etcd.io/etcd/etcdctl/v3 v3.0.0-00010101000000-000000000000 - go.etcd.io/etcd/pkg/v3 v3.0.0-00010101000000-000000000000 - go.etcd.io/etcd/raft/v3 v3.0.0-00010101000000-000000000000 - go.etcd.io/etcd/server/v3 v3.0.0-00010101000000-000000000000 + go.etcd.io/etcd/api/v3 v3.5.0-pre + go.etcd.io/etcd/client/v2 v2.305.0-pre + go.etcd.io/etcd/client/v3 v3.5.0-pre + go.etcd.io/etcd/etcdctl/v3 v3.5.0-pre + go.etcd.io/etcd/pkg/v3 v3.5.0-pre + go.etcd.io/etcd/raft/v3 v3.5.0-pre + go.etcd.io/etcd/server/v3 v3.5.0-pre go.uber.org/zap v1.16.0 golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0 golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e