diff --git a/.gitignore b/.gitignore index d9a5081d255..3307a3850f8 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,6 @@ site/public/ site/resources/ site/.hugo_build.lock **/node_modules/ + +# goreleaser artifacts +**/dist/ diff --git a/releasing/README.md b/releasing/README.md index 38418f674a6..cfcef544b2b 100644 --- a/releasing/README.md +++ b/releasing/README.md @@ -141,7 +141,7 @@ go mod edit -require=sigs.k8s.io/kustomize/kyaml@$versionKyaml plugin/builtin/pa Create the PR: ``` -createBranch pinToKyaml "Pin to kyaml $versionKyaml" +createBranch pinToKyaml "Update kyaml to $versionKyaml" ``` ``` createPr @@ -201,7 +201,7 @@ gorepomod pin cmd/config --doIt Create the PR: ``` -createBranch pinToCmdConfig "Pin to cmd/config $versionCmdConfig" && +createBranch pinToCmdConfig "Update cmd/config to $versionCmdConfig" && createPr ``` @@ -256,7 +256,7 @@ gorepomod pin api --doIt Create the PR: ``` -createBranch pinToApi "Pin to api $versionApi" && +createBranch pinToApi "Update api to $versionApi" && createPr ``` @@ -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/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/cloudbuild.yaml b/releasing/cloudbuild.yaml index f22d9b18a28..55ab7466229 100644 --- a/releasing/cloudbuild.yaml +++ b/releasing/cloudbuild.yaml @@ -36,7 +36,7 @@ steps: # Run goreleaser indirectly via a shell script # to configure it properly. -- name: goreleaser/goreleaser:v0.172.1 +- name: goreleaser/goreleaser:v0.179.0 timeout: 12m entrypoint: /bin/sh dir: myClone diff --git a/releasing/compile-changelog.sh b/releasing/compile-changelog.sh new file mode 100755 index 00000000000..e79b9269688 --- /dev/null +++ b/releasing/compile-changelog.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# +# Builds a PR-oriented changelog from the git history for the given module. +# +# Usage (from top of repo): +# +# releasing/compile-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") ) + +# There is a 256 character limit on the query parameter for the GitHub API, so split into batches then deduplicate results +batchSize=5 +results="" +for((i=0; i < ${#commits[@]}; i+=batchSize)) +do + commitList=$(IFS="+"; echo "${commits[@]:i:batchSize}" | sed 's/ /+/g') + if newResults=$(curl -sSL "https://api.github.com/search/issues?q=$commitList+repo%3Akubernetes-sigs%2Fkustomize" | jq -r '[ .items[] | { number, title } ]'); then + results=$(echo "$results" "$newResults" | jq -s '.[0] + .[1] | unique') + else + echo "Failed to fetch results for commits: $commitList" + exit 1 + fi +done + +echo "${results}" | jq -r '.[] | select( .title | startswith("Back to development mode") | not) | "#\(.number): \(.title)" ' > "$changeLogFile" diff --git a/releasing/localbuild.sh b/releasing/run-goreleaser.sh similarity index 57% rename from releasing/localbuild.sh rename to releasing/run-goreleaser.sh index 02bb7bbf1ba..328f1c616b4 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/compile-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,16 +126,26 @@ release: EOF -cat $goReleaserConfigFile +echo +echo "############# CONFIG ##############" +cat "$goReleaserConfigFile" +echo "###################################" +echo + +args=( + --debug + --timeout 10m + --parallelism 7 + --config="$goReleaserConfigFile" + --rm-dist + --skip-validate +) +if [[ $mode == "release" ]]; then + args+=(--release-notes="$changeLogFile") +fi date - -time /usr/local/bin/goreleaser build \ - --debug \ - --timeout 10m \ - --parallelism 7 \ - --config=$goReleaserConfigFile \ - --rm-dist \ - --skip-validate $remainingArgs - +export PATH="/usr/local/bin:$PATH" +set -x +time goreleaser "$mode" "${args[@]}" $remainingArgs date