From 4eb2d5bcc2262880d23c8a0e74ffc504752eda1c Mon Sep 17 00:00:00 2001 From: Jeffrey Regan Date: Mon, 7 Oct 2019 14:20:05 -0700 Subject: [PATCH] Three builders. --- releasing/README.md | 17 +++- releasing/cloudbuild.sh | 87 +++++++++++++++++-- ...udbuild.yaml => cloudbuild_kustomize.yaml} | 2 +- releasing/cloudbuild_pluginator.yaml | 11 +++ releasing/goreleaser.yaml | 38 -------- releasing/localbuild.sh | 47 ++++++++-- 6 files changed, 143 insertions(+), 59 deletions(-) rename releasing/{cloudbuild.yaml => cloudbuild_kustomize.yaml} (90%) create mode 100644 releasing/cloudbuild_pluginator.yaml delete mode 100644 releasing/goreleaser.yaml diff --git a/releasing/README.md b/releasing/README.md index 95977e99a..db67a45c7 100644 --- a/releasing/README.md +++ b/releasing/README.md @@ -70,8 +70,19 @@ require sigs.k8s.io/kustomize/v4 v4.0.1 #### Release artifacts -Source code tar balls and zip files (no executables) -appear on the [release page]. +Release notes should appear on the [release page]. + +[release notes generator]: https://github.com/kubernetes-sigs/controller-runtime/blob/master/hack/release/release-notes.sh + +> TODO: install a decent library [release notes generator]. +> Until then, just run something like +> ``` +> git log --pretty="%h - %s (%aN)" v3.1.0..v3.2.0 +> ``` +> and summarize the results via the [release page] UX. + +There's no binary, just a repo tag in the form `v4.3.2` +that others can `require` from their `go.mod` files. ### sigs.k8s.io/kustomize/pluginator @@ -190,7 +201,7 @@ fi Install [`cloud-build-local`], then run ``` -./releasing/localbuild.sh +./releasing/localbuild.sh (kustomize|pluginator) ``` This should create release artifacts in a local directory. diff --git a/releasing/cloudbuild.sh b/releasing/cloudbuild.sh index 52a620cfc..3e262f800 100755 --- a/releasing/cloudbuild.sh +++ b/releasing/cloudbuild.sh @@ -2,14 +2,85 @@ set -e set -x -# goreleaser must be run from the _module_ being released. -cd kustomize +# Script to run http://goreleaser.com -/bin/goreleaser \ - release \ - --config=../releasing/goreleaser.yaml \ - --rm-dist \ - --skip-validate \ - $@ +module=$1 +shift + +if [ "$module" == "api" ]; then + echo "goreleaser only releases 'main' packages (executables)" + echo "See https://github.com/goreleaser/goreleaser/issues/981" + exit 1 +fi + +config=$(mktemp) + +cat <$config +project_name: $module +env: +- CGO_ENABLED=0 +- GO111MODULE=on +checksum: + name_template: 'checksums.txt' +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' + - Merge pull request + - Merge branch +release: + github: + owner: kubernetes-sigs + name: kustomize +EOF + +case "$module" in + kustomize) + cat <>$config +builds: +- main: ./main.go + binary: kustomize + ldflags: -s -X sigs.k8s.io/kustomize/kustomize/v3/provenance.version={{.Version}} -X sigs.k8s.io/kustomize/kustomize/v3/provenance.gitCommit={{.Commit}} -X sigs.k8s.io/kustomize/kustomize/v3/provenance.buildDate={{.Date}} + goos: + - linux + - darwin + - windows + goarch: + - amd64 +archive: + format: binary +EOF + ;; + pluginator) + cat <>$config +builds: +- main: ./main.go + binary: pluginator + goos: + - linux + - darwin + - windows + goarch: + - amd64 +archive: + format: binary +EOF + ;; + *) + echo "Don't recognize module $module" + exit 1 + ;; +esac + +cat $config + +if [ "$module" != "api" ]; then + # goreleaser must be run from the _module_ being released. + cd $module +fi + +/bin/goreleaser release --config=$config --rm-dist --skip-validate $@ diff --git a/releasing/cloudbuild.yaml b/releasing/cloudbuild_kustomize.yaml similarity index 90% rename from releasing/cloudbuild.yaml rename to releasing/cloudbuild_kustomize.yaml index 7340218c4..d7d83beca 100644 --- a/releasing/cloudbuild.yaml +++ b/releasing/cloudbuild_kustomize.yaml @@ -3,7 +3,7 @@ steps: args: [fetch, --tags, --depth=100] - name: goreleaser/goreleaser entrypoint: /bin/sh - args: ["releasing/cloudbuild.sh"] + args: ["releasing/cloudbuild.sh", "kustomize"] secretEnv: ['GITHUB_TOKEN'] secrets: - kmsKeyName: projects/kustomize-199618/locations/global/keyRings/github-tokens/cryptoKeys/gh-release-token diff --git a/releasing/cloudbuild_pluginator.yaml b/releasing/cloudbuild_pluginator.yaml new file mode 100644 index 000000000..365c85a3c --- /dev/null +++ b/releasing/cloudbuild_pluginator.yaml @@ -0,0 +1,11 @@ +steps: +- name: "gcr.io/cloud-builders/git" + args: [fetch, --tags, --depth=100] +- name: goreleaser/goreleaser + entrypoint: /bin/sh + args: ["releasing/cloudbuild.sh", "pluginator"] + secretEnv: ['GITHUB_TOKEN'] +secrets: +- kmsKeyName: projects/kustomize-199618/locations/global/keyRings/github-tokens/cryptoKeys/gh-release-token + secretEnv: + GITHUB_TOKEN: CiQAyrREbPgXJOeT7M3t+WlxkhXwlMPudixBeiyWTjmLOMLqdK4SUQA0W+xUmDJKAhyfHCcwqSEzUn9OwKC7XAYcmwe0CCKTCbPbDgmioDK24q3LVapndXNvnnHvCjhOJNEr1o+P1DCF+LlzYV2YL8lP09rrKrslPg== diff --git a/releasing/goreleaser.yaml b/releasing/goreleaser.yaml deleted file mode 100644 index e62992b4a..000000000 --- a/releasing/goreleaser.yaml +++ /dev/null @@ -1,38 +0,0 @@ -# Documentation at http://goreleaser.com -# By default, output sent to ./dist (see docs). -# -# 2019-may-29: windows removed because of error -# pkg/plugins/execplugin.go:111:2: undefined: syscall.Mkfifo -# -project_name: kustomize -builds: -- main: ./main.go - binary: kustomize - ldflags: -s -X sigs.k8s.io/kustomize/kustomize/v3/provenance.version={{.Version}} -X sigs.k8s.io/kustomize/kustomize/v3/provenance.gitCommit={{.Commit}} -X sigs.k8s.io/kustomize/kustomize/v3/provenance.buildDate={{.Date}} - goos: - - linux - - darwin - - windows - goarch: - - amd64 - env: - - CGO_ENABLED=0 - - GO111MODULE=on -checksum: - name_template: 'checksums.txt' -archive: - format: binary -snapshot: - name_template: "master" -changelog: - sort: asc - filters: - exclude: - - '^docs:' - - '^test:' - - Merge pull request - - Merge branch -release: - github: - owner: kubernetes-sigs - name: kustomize diff --git a/releasing/localbuild.sh b/releasing/localbuild.sh index bb3839652..f2fb06b9f 100755 --- a/releasing/localbuild.sh +++ b/releasing/localbuild.sh @@ -2,7 +2,7 @@ # Usage - from the repository root, enter # -# ./releasing/localbuild.sh +# ./releasing/localbuild.sh (kustomize|pluginator) # # The script attempts to use cloudbuild configuration # to create a release "locally". @@ -17,25 +17,53 @@ # applied to the kustomize repo, the cloud builder # reads the repository-relative file # -# releasing/cloudbuild.yaml +# releasing/cloudbuild_(kustomize|pluginator).yaml # # Inside this yaml file is a reference to the script # # releasing/cloudbuild.sh # -# which runs goreleaser from the proper directory. +# which runs goreleaser from the proper directory, with the +# proper config. # # The script you are reading now does something # analogous via docker tricks. set -e -# Modify cloudbuild.yaml to add the --snapshot flag. -# This suppresses the github release, and leaves -# the build output in the kustomize/dist directory. +module=$1 +case "$module" in + api) + echo "goreleaser only releases 'main' packages (executables)" + echo "See https://github.com/goreleaser/goreleaser/issues/981" + exit 1 + ;; + kustomize) + ;; + pluginator) + ;; + *) + echo "Don't recognize module=$module" + exit 1 + ;; +esac + config=$(mktemp) -sed 's|\["releasing/cloudbuild.sh"\]|["releasing/cloudbuild.sh", "--snapshot"]|' \ - releasing/cloudbuild.yaml > $config +cp releasing/cloudbuild_${module}.yaml $config + +# Delete the cloud-builders/git step. +sed -i '2,3d' $config + +# Add the --snapshot flag to suppress the +# github release and leave the build output +# in the kustomize/dist directory. +sed -i 's|"\]$|", "--snapshot"]|' \ + $config + +echo "Executing cloud-build-local with:" +echo "=========================" +cat $config +echo "=========================" cloud-build-local \ --config=$config \ @@ -43,7 +71,8 @@ cloud-build-local \ --dryrun=false \ . -# Print results of local build +echo " " +echo "Result of local build:" echo "##########################################" tree ./kustomize/dist echo "##########################################"