diff --git a/releasing/README.md b/releasing/README.md index 38418f674a6..020033a5ae8 100644 --- a/releasing/README.md +++ b/releasing/README.md @@ -383,7 +383,7 @@ Image sha256 can be found in the image registry in the GCP project [k8s-staging-kustomize]. Commit and push your changes. Then create a PR to [k8s.io] to promote -new images. Assign the PR to @monopole and @Shell32-natsu. +the new image. ## Update kustomize-in-kubectl diff --git a/releasing/build-changelog.sh b/releasing/build-changelog.sh new file mode 100755 index 00000000000..16b6acc77cd --- /dev/null +++ b/releasing/build-changelog.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# +# Builds a PR-oriented changelog from the git history for the given module. +# +# Usage (from top of repo): +# +# releasing/build-changelog.sh MODULE TAG CHANGE_LOG_FILE +# +# Where TAG is in the form +# +# api/v1.2.3 +# kustomize/v1.2.3 +# cmd/config/v1.2.3 +# ... etc. +# + +set -o errexit +set -o nounset +set -o pipefail + +if [[ -z "${1-}" ]] || [[ -z "${2-}" ]] || [[ -z "${3-}" ]]; then + echo "Usage: $0 " + echo "Example: $0 kyaml kyaml/v0.13.4 changelog.txt" + exit 1 +fi + +module=$1 +fullTag=$2 +changeLogFile=$3 + +# Find previous tag that matches the tags module +prevTag=$(git tag -l "$module*" --sort=-version:refname --no-contains="$fullTag" | head -n 1) + +commits=$(git log "$prevTag".."$fullTag" \ + --pretty=format:'%h' \ + --abbrev-commit --no-decorate --no-color --no-merges \ + -- "$module") + +commitList=$(echo "$commits" | paste -s -d'+' -) + +curl -sL "https://api.github.com/search/issues?q=$commitList+repo%3Akubernetes-sigs%2Fkustomize" | jq -r '.items[] | "#\(.number): \(.title) "' > "$changeLogFile" diff --git a/releasing/cloudbuild.sh b/releasing/cloudbuild.sh index ce73e6b45a8..8e2f1e10d4f 100755 --- a/releasing/cloudbuild.sh +++ b/releasing/cloudbuild.sh @@ -24,108 +24,5 @@ set -x fullTag=$1 shift -echo "fullTag=$fullTag" -remainingArgs="$@" -echo "Remaining args: $remainingArgs" - -# Take everything before the last slash. -# This is expected to match $module. -module=${fullTag%/*} -echo "module=$module" - -# Find previous tag that matches the tags module -prevTag=$(git tag -l "$module*" --sort=-version:refname --no-contains=$fullTag | head -n 1) - -# Generate the changelog for this release -# using the last two tags for the module -changeLogFile=$(mktemp) -git log $prevTag..$fullTag \ - --pretty=oneline \ - --abbrev-commit --no-decorate --no-color --no-merges \ - -- $module > $changeLogFile -echo "Release notes:" -cat $changeLogFile - -# Take everything after the last slash. -# This should be something like "v1.2.3". -semVer=`echo $fullTag | sed "s|$module/||"` -echo "semVer=$semVer" - -# This is probably a directory called /workspace -echo "pwd = $PWD" - -# Sanity check -echo "### ls -las . ################################" -ls -las . -echo "###################################" - - -# CD into the module directory. -# This directory expected to contain a main.go, so there's -# no need for extra details in the `build` stanza below. -cd $module - -skipBuild=true -if [[ "$module" == "kustomize" || "$module" == "pluginator" ]]; then - # If releasing a main program, don't skip the build. - skipBuild=false -fi - -goReleaserConfigFile=$(mktemp) - -cat <$goReleaserConfigFile -project_name: $module - -archives: -- name_template: "${module}_${semVer}_{{ .Os }}_{{ .Arch }}" - -builds: -- skip: $skipBuild - - ldflags: > - -s - -X sigs.k8s.io/kustomize/api/provenance.version={{.Version}} - -X sigs.k8s.io/kustomize/api/provenance.gitCommit={{.Commit}} - -X sigs.k8s.io/kustomize/api/provenance.buildDate={{.Date}} - - goos: - - linux - - darwin - - windows - - goarch: - - amd64 - - arm64 - - s390x - - ppc64le - -checksum: - name_template: 'checksums.txt' - -env: -- CGO_ENABLED=0 -- GO111MODULE=on - -release: - github: - owner: kubernetes-sigs - name: kustomize - draft: true - -EOF - -cat $goReleaserConfigFile - -date - -time /usr/local/bin/goreleaser release \ - --debug \ - --timeout 10m \ - --parallelism 7 \ - --config=$goReleaserConfigFile \ - --release-notes=$changeLogFile \ - --rm-dist \ - --skip-validate $remainingArgs - -date +./releasing/run-goreleaser.sh "$fullTag" release "$@" diff --git a/releasing/localbuild.sh b/releasing/run-goreleaser.sh similarity index 62% rename from releasing/localbuild.sh rename to releasing/run-goreleaser.sh index 02bb7bbf1ba..357dd361693 100755 --- a/releasing/localbuild.sh +++ b/releasing/run-goreleaser.sh @@ -1,10 +1,10 @@ #!/bin/bash # -# Works exactly like cloudbuild.sh but doesn't perform a release. +# Builds and optionally releases the specified module # # Usage (from top of repo): # -# releasing/localbuild.sh TAG [--snapshot] +# releasing/localbuild.sh TAG MODE[build|release] [--snapshot] # # Where TAG is in the form # @@ -13,56 +13,70 @@ # cmd/config/v1.2.3 # ... etc. # -# This script runs a build through goreleaser (http://goreleaser.com) but nothing else. -# -set -e -set -x +set -o errexit +set -o nounset +set -o pipefail + +if [[ -z "${1-}" || -z "${2-}" ]]; then + echo "Usage: $0 TAG MODE [goreleaser flags]" + echo " TAG: the tag to build or release, e.g. api/v1.2.3" + echo " MODE: build or release" + exit 1 +fi fullTag=$1 shift echo "fullTag=$fullTag" +if [[ $1 == "release" || $1 == "build" ]]; then + mode=$1 + shift +else + echo "Error: mode must be build or release" + exit 1 +fi + remainingArgs="$@" -echo "Remaining args: $remainingArgs" +echo "Remaining args: $remainingArgs" # Take everything before the last slash. # This is expected to match $module. module=${fullTag%/*} echo "module=$module" -# Find previous tag that matches the tags module -prevTag=$(git tag -l "$module*" --sort=-version:refname --no-contains=$fullTag | head -n 1) +# Take everything after the last slash. +# This should be something like "v1.2.3". +semVer=${fullTag#$module/} +echo "semVer=$semVer" # Generate the changelog for this release # using the last two tags for the module changeLogFile=$(mktemp) -git log $prevTag..$fullTag \ - --pretty=oneline \ - --abbrev-commit --no-decorate --no-color --no-merges \ - -- $module > $changeLogFile -echo "Release notes:" -cat $changeLogFile - -# Take everything after the last slash. -# This should be something like "v1.2.3". -semVer=`echo $fullTag | sed "s|$module/||"` -echo "semVer=$semVer" +./releasing/build-changelog.sh "$module" "$fullTag" "$changeLogFile" +echo +echo "######### Release notes: ##########" +cat "$changeLogFile" +echo "###################################" +echo # This is probably a directory called /workspace -echo "pwd = $PWD" # Sanity check -echo "### ls -las . ################################" +echo +echo "############ DEBUG ##############" +echo "pwd = $PWD" +echo "ls -las ." ls -las . echo "###################################" - +echo # CD into the module directory. # This directory expected to contain a main.go, so there's # no need for extra details in the `build` stanza below. cd $module +# This is used in goreleaser.yaml skipBuild=true if [[ "$module" == "kustomize" || "$module" == "pluginator" ]]; then # If releasing a main program, don't skip the build. @@ -112,15 +126,20 @@ release: EOF -cat $goReleaserConfigFile +echo +echo "############# CONFIG ##############" +cat "$goReleaserConfigFile" +echo "###################################" +echo date -time /usr/local/bin/goreleaser build \ +time /usr/local/bin/goreleaser "$mode" \ --debug \ --timeout 10m \ --parallelism 7 \ - --config=$goReleaserConfigFile \ + --config="$goReleaserConfigFile" \ + --release-notes="$changeLogFile" \ --rm-dist \ --skip-validate $remainingArgs