diff --git a/cmd/config/fixgomod.sh b/cmd/config/fixgomod.sh new file mode 100755 index 000000000..62a930c88 --- /dev/null +++ b/cmd/config/fixgomod.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# Copyright 2019 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +set -e + +: "${kyaml_major?Need to source VERSIONS}" +: "${kyaml_minor?Need to source VERSIONS}" +: "${kyaml_patch?Need to source VERSIONS}" + +go mod edit -dropreplace=sigs.k8s.io/kustomize/kyaml@v0.0.0 +go mod edit -require=sigs.k8s.io/kustomize/kyaml@v$kyaml_major.$kyaml_minor.$kyaml_patch diff --git a/cmd/kubectl/fixgomod.sh b/cmd/kubectl/fixgomod.sh new file mode 100755 index 000000000..62a930c88 --- /dev/null +++ b/cmd/kubectl/fixgomod.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# Copyright 2019 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +set -e + +: "${kyaml_major?Need to source VERSIONS}" +: "${kyaml_minor?Need to source VERSIONS}" +: "${kyaml_patch?Need to source VERSIONS}" + +go mod edit -dropreplace=sigs.k8s.io/kustomize/kyaml@v0.0.0 +go mod edit -require=sigs.k8s.io/kustomize/kyaml@v$kyaml_major.$kyaml_minor.$kyaml_patch diff --git a/kustomize/fixgomod.sh b/kustomize/fixgomod.sh new file mode 100755 index 000000000..4768991cb --- /dev/null +++ b/kustomize/fixgomod.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Copyright 2019 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +set -e + +: "${api_major?Need to source VERSIONS}" +: "${api_minor?Need to source VERSIONS}" +: "${api_patch?Need to source VERSIONS}" + +: "${kyaml_major?Need to source VERSIONS}" +: "${kyaml_minor?Need to source VERSIONS}" +: "${kyaml_patch?Need to source VERSIONS}" + +: "${cmd_config_major?Need to source VERSIONS}" +: "${cmd_config_minor?Need to source VERSIONS}" +: "${cmd_config_patch?Need to source VERSIONS}" + +: "${cmd_kubectl_major?Need to source VERSIONS}" +: "${cmd_kubectl_minor?Need to source VERSIONS}" +: "${cmd_kubectl_patch?Need to source VERSIONS}" + + +# api +go mod edit -dropreplace=sigs.k8s.io/kustomize/api@v0.0.0 +go mod edit -require=sigs.k8s.io/kustomize/api@v$api_major.$api_minor.$api_patch + +# kyaml +go mod edit -dropreplace=sigs.k8s.io/kustomize/kyaml@v0.0.0 +go mod edit -require=sigs.k8s.io/kustomize/kyaml@v$kyaml_major.$kyaml_minor.$kyaml_patch + +# cmd/config +go mod edit -dropreplace=sigs.k8s.io/kustomize/cmd/config@v0.0.0 +go mod edit -require=sigs.k8s.io/kustomize/cmd/config@v$cmd_config_major.$cmd_config_minor.$cmd_config_patch + +# cmd/kubectl +go mod edit -dropreplace=sigs.k8s.io/kustomize/cmd/kubectl@v0.0.0 +go mod edit -require=sigs.k8s.io/kustomize/cmd/kubectl@v$cmd_kubectl_major.$cmd_kubectl_minor.$cmd_kubectl_patch diff --git a/releasing/VERSIONS b/releasing/VERSIONS new file mode 100644 index 000000000..e35ba377d --- /dev/null +++ b/releasing/VERSIONS @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +# VERSIONS contains the release versions of each kustomize go module +# update this file and run releaseall.sh to cut a new release + +# kyaml version +export kyaml_major=0 +export kyaml_minor=0 +export kyaml_patch=1 + +# kustomize api version +export api_major=0 +export api_minor=3 +export api_patch=0 + +# cmd/config version +export cmd_config_major=0 +export cmd_config_minor=0 +export cmd_config_patch=1 + +# cmd/kubectl version +export cmd_kubectl_major=0 +export cmd_kubectl_minor=0 +export cmd_kubectl_patch=1 + +# kustomize version +export kustomize_major=3 +export kustomize_minor=5 +export kustomize_patch=1 diff --git a/releasing/releaseallmodules.sh b/releasing/releaseallmodules.sh new file mode 100755 index 000000000..87a146f60 --- /dev/null +++ b/releasing/releaseallmodules.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# Copyright 2019 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +set -e + +# fetch upstream once +git fetch upstream +export FETCH="false" + +# release modules without binaries +for module in "kyaml api cmd/config cmd/kubectl" +do + releasing/releasemodule.sh $module +done + +# release modules with binaries +for binary in "kustomize" +do + BINARY=true releasing/releasemodule.sh $binary +done diff --git a/releasing/releasemodule.sh b/releasing/releasemodule.sh new file mode 100755 index 000000000..4d1096d4c --- /dev/null +++ b/releasing/releasemodule.sh @@ -0,0 +1,104 @@ +#!/bin/bash +# Copyright 2019 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +# run this script with releasing/releasemodule.sh MODULE +# -- e.g. releasing/releasemodule.sh cmd/config +# to push the latest tag to release a binary, run with BINARY=true +# -- e.g. BINARY=true releasing/releasemodule.sh kustomize +# to skip fetch from upstream, run with FETCH=false +# -- e.g. FETCH=false releasing/releasemodule.sh kyaml +# for a list of modules see releasing/releaseallmodules.sh +set -e + +# perform release for a module +function releaseModule { + # calculate the branch and tag names + module=$1 + slash="/" + module_name=${module/$slash/_} + name="${module_name}_major" + major="${!name}" + name="${module_name}_minor" + minor="${!name}" + name="${module_name}_patch" + patch="${!name}" + branch="release-${module}-v${major}.${minor}" + tag="${module}/v${major}.${minor}.${patch}" + + # create a temporary workspace for our work + wktree=$(mktemp -d /tmp/kustomize-releases-XXXXXX) + git branch -f $branch upstream/master # always release from master + git worktree add $wktree $branch # create a separate worktree for the branch + pushd . + cd $wktree/$module # cd into the worktree/module + + echo "dir: $wktree" + echo "module: $module v$major.$minor.$patch" + echo "branch: $branch" + echo "tag: $tag" + + # clean up replaces in go.mod as needed + FILE=fixgomod.sh + if test -f "$FILE"; then + ./fixgomod.sh + + go mod tidy + go test ./... + go mod tidy + git add . + git commit -m "update go.mod for release" || echo "no changes made to go.mod" + fi + + if [ "$NO_DRY_RUN" == "true" ]; then + git push upstream $branch + git tag -a $tag -m "Release $tag on branch $branch" + git push upstream $tag + else + printf "\nSkipping push binary $binary -- run with NO_DRY_RUN=true to push the release.\n\n" + fi + + # cleanup release artifacts + popd + rm -rf $wktree + git worktree prune + git branch -D $branch + echo "$module complete" +} + +function releaseBinary { + # move the latest tag for the binary to trigger cloudbuild + binary=$1 + echo "binary: $binary" + + if [ "$NO_DRY_RUN" == "true" ]; then + git tag -d latest_$binary + git push upstream :latest_$binary + git tag -a latest_$binary + git push upstream latest_$binary + else + echo "Skipping push binary $binary -- run with NO_DRY_RUN=true to push the release." + fi +} + +# configure the branch and tag names +module="${1?must provide the module to release as an argument}" + +# get the release versions +source releasing/VERSIONS + +FETCH=${FETCH:-"true"} +NO_DRY_RUN=${NO_DRY_RUN:-"false"} + +# get the most recent changes +if [ "$FETCH" == "true" ]; then + git fetch upstream +fi + +# release the module +releaseModule $module + +# release the binary +if [ "$BINARY" == "true" ]; then + releaseBinary $module +fi