diff --git a/RELEASE.md b/RELEASE.md index 4f00aad65b7..3c130a888b2 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -86,13 +86,8 @@ The releases occur in an account in the Google Cloud (See [here](https://console ### To build the Kubebuilder CLI binaries: -A trigger `build-kb-release` is configured to call [build/cloudbuild.yaml](build/cloudbuild.yaml). -This trigger will be executed when any new tag be published. -The tags must be built from the release branch (Currently, `release-3`). - -Also, we have a trigger to generate snapshots builds from the master branch. -This trigger will call [build/cloudbuild_snapshot.yaml](build/cloudbuild_snapshot.yaml) -when any change needs to be performed on master. +A trigger GitHub action [release](.github/workflows/release.yml) is trigged when a new tag is pushed. +This action will caall the job [./build/.goreleaser.yml](./build/.goreleaser.yml). ### To build the Kubebuilder-tools: (Artifacts required to use ENV TEST) diff --git a/build/build_kubebuilder.sh b/build/build_kubebuilder.sh deleted file mode 100755 index 6569396b865..00000000000 --- a/build/build_kubebuilder.sh +++ /dev/null @@ -1,111 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2018 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# This script runs goreleaser using the build/.goreleaser.yml config. -# While it can be run locally, it is intended to be run by cloudbuild -# in the goreleaser/goreleaser image. - -function usage() { - echo " - This script runs goreleaser using the build/.goreleaser.yml config. - While it can be run locally, it is intended to be run by cloudbuild - in the goreleaser/goreleaser image. - - GORELEASER_FLAGS: contains flags to pass to the goreleaser binary (default: only --config is set). - - SNAPSHOT: if set to any value, runs goreleaser in snapshot mode with mock release notes (default: unset). - - NOTES_FLAGS: contains flags to pass to the notes binary (sigs.k8s.io/kubebuilder-release-tools/notes). - Does nothing if SNAPSHOT is set. (default: unset). - - Examples: - - # Run in snapshot mode: fake release notes, nothing is published, binaries build in '$(pwd)/dist' - \$ SNAPSHOT=1 $0 - - # Add a release type to the release notes - \$ NOTES_FLAGS=\"-r beta\" $0 -" -} - -# GORELEASER_FLAGS contains flags for goreleaser such that the binary can be run -# in local/snapshot/prod mode from the same script. -# NOTE: if --snapshot is in GORELEASER_FLAGS, the release is not published to GitHub -# and the build is available under $PWD/dist. -GORELEASER_FLAGS="${GORELEASER_FLAGS:-}" -# NOTES_FLAGS contains flags for the release notes generator (see install_notes for details). -NOTES_FLAGS="${NOTES_FLAGS:-}" -# SNAPSHOT is set by the CLI flag parser if --snapshot is a passed flag. -# If not set, release notes are not generated. -SNAPSHOT="${SNAPSHOT:-}" - -while [ $# -gt 0 ]; do - case $1 in - -h|--help) - usage - exit 0 - ;; - esac -done - - -# install_notes installs kubebuilder's release notes generator globally with name "notes". -function install_notes() { - local tmp=$(mktemp -d) - pushd "$tmp" - go mod init tmp - # Get by commit because v0.1.1 cannot be retrieved via `go get`. - go get sigs.k8s.io/kubebuilder-release-tools/notes@4777888c377a26956f1831d5b9207eea1fa3bf29 - popd - rm -rf "$tmp" -} - -set -o errexit -set -o pipefail - -# Generate real release notes. -if [ -z "$SNAPSHOT" ]; then - tmp_notes="$(mktemp)" - trap "rm -f ${tmp_notes}" EXIT - install_notes - if [[ -n "${CLOUD_BUILD}" ]]; then - # we refresh just before this, no point (plus, we fiddle with the current branch a bit) - NOTES_FLAGS+=" --use-upstream=false" - # we can look for tag alpha/beta here too - # (TODO(directxman12): this should be in the tool) - [[ "${TAG_NAME}" == "v"*"-alpha."* ]] && NOTES_FLAGS+=" -r alpha" - [[ "${TAG_NAME}" == "v"*"-beta."* ]] && NOTES_FLAGS+=" -r beta" - [[ "${TAG_NAME}" == "v"*"-rc."* ]] && NOTES_FLAGS+=" -r rc" - fi - # TODO(cmacedo): figure out how to download the release notes and let it available in the cloud build - # Currently it does not work: https://github.com/kubernetes-sigs/kubebuilder/issues/2667 - # notes $NOTES_FLAGS | tee "$tmp_notes" - notes="Mock Release Notes for $(git describe --tags --always --broken)" - # we need to delete the tag for the release notes script, so restore it when done so that - # go releaser can find the right tag - if [[ -n "${TAG_NAME}" ]]; then - git tag ${TAG_NAME} - fi - GORELEASER_FLAGS="${GORELEASER_FLAGS} --release-notes=${tmp_notes}" -else - # TODO(estroz): figure out how to generate snapshot release notes with the kubebuilder generator. - echo "Running in snapshot mode. Release notes will not be generated from commits." - notes="Mock Release Notes for $(git describe --tags --always --broken)" - GORELEASER_FLAGS="${GORELEASER_FLAGS} --snapshot --rm-dist --skip-validate --release-notes <(echo \"${notes}\")" -fi - -# eval to run process substitution. -eval goreleaser release --config=build/.goreleaser.yml $GORELEASER_FLAGS diff --git a/build/cloudbuild.yaml b/build/cloudbuild.yaml deleted file mode 100644 index 70c62748c40..00000000000 --- a/build/cloudbuild.yaml +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright 2018 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Instructions to run locally: -# Download google container builder: https://github.com/GoogleCloudPlatform/cloud-build-local -# $ mkdir cloudbuild -# $ cloud-build-local --config=build/cloudbuild_local.yaml --dryrun=false --write-workspace=./cloudbuild . -# Release tar will be in ./cloudbuild - -steps: -- name: "gcr.io/cloud-builders/git" - entrypoint: 'bash' - args: - - '-c' - - | - git fetch --tags --unshallow - git for-each-ref --contains HEAD - # TAG_NAME is defined by GCB, so uses 1 dollar sign, BRANCH_NAME is bash, so we need to escape it - # with two dollar signs - export BRANCH_NAME=$(git for-each-ref --format="%(refname:strip=-1)" --contains HEAD 'refs/remotes/origin/release-*') - export ALL_BRANCHES=$(git for-each-ref --format="%(refname:strip=-1)" 'refs/remotes/origin/release-*') - echo "branch: $${BRANCH_NAME}, tag: ${TAG_NAME}, all release branches: $${ALL_BRANCHES}" - for branch in $${ALL_BRANCHES}; do - git branch $${branch} origin/$${branch} - done - git branch -f $${BRANCH_NAME} HEAD - git checkout $${BRANCH_NAME} - git branch --set-upstream-to=origin/$${BRANCH_NAME} - git tag -d ${TAG_NAME} -- name: "goreleaser/goreleaser:v1.11.2" - entrypoint: "bash" - args: ["build/build_kubebuilder.sh"] - env: - - 'TAG_NAME=$TAG_NAME' - - 'CLOUD_BUILD=true' - - 'GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}' \ No newline at end of file diff --git a/build/cloudbuild_local.yaml b/build/cloudbuild_local.yaml deleted file mode 100644 index ed97f90aa34..00000000000 --- a/build/cloudbuild_local.yaml +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2018 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Instructions to run locally: -# Download google container builder: https://github.com/GoogleCloudPlatform/cloud-build-local -# $ mkdir cloudbuild -# $ cloud-build-local --config=build/cloudbuild_local.yaml --dryrun=false --write-workspace=./cloudbuild . -# Release tar will be in ./cloudbuild - -steps: -- name: "goreleaser/goreleaser:v1.11.2" - entrypoint: "bash" - env: ["SNAPSHOT=1"] - args: ["build/build_kubebuilder.sh"] diff --git a/build/cloudbuild_snapshot.yaml b/build/cloudbuild_snapshot.yaml deleted file mode 100644 index 9eaf2d4ffc4..00000000000 --- a/build/cloudbuild_snapshot.yaml +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright 2018 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Instructions to run locally: -# Download google container builder: https://github.com/GoogleCloudPlatform/cloud-build-local -# $ mkdir cloudbuild -# $ cloud-build-local --config=build/cloudbuild_snapshot.yaml --dryrun=false --write-workspace=./cloudbuild . -# Release tar will be in ./cloudbuild - -steps: -- name: "goreleaser/goreleaser:v1.11.2" - entrypoint: "bash" - env: ["SNAPSHOT=1"] - args: ["build/build_kubebuilder.sh"] - timeout: 30m -- name: "ubuntu" - args: ["tar", "-zcvf", "kubebuilder_linux_amd64.tar.gz", "-C", "dist/kubebuilder_linux_amd64_v1", "kubebuilder"] -- name: "gcr.io/cloud-builders/gsutil" - args: ["-h", "Content-Type:application/gzip", "cp", "kubebuilder_linux_amd64.tar.gz", "gs://kubebuilder-release/kubebuilder_master_linux_amd64.tar.gz"] -- name: "ubuntu" - args: ["tar", "-zcvf", "kubebuilder_linux_arm64.tar.gz", "-C", "dist/kubebuilder_linux_arm64", "kubebuilder"] -- name: "gcr.io/cloud-builders/gsutil" - args: ["-h", "Content-Type:application/gzip", "cp", "kubebuilder_linux_arm64.tar.gz", "gs://kubebuilder-release/kubebuilder_master_linux_arm64.tar.gz"] -- name: "ubuntu" - args: ["tar", "-zcvf", "kubebuilder_linux_ppc64le.tar.gz", "-C", "dist/kubebuilder_linux_ppc64le", "kubebuilder"] -- name: "gcr.io/cloud-builders/gsutil" - args: ["-h", "Content-Type:application/gzip", "cp", "kubebuilder_linux_ppc64le.tar.gz", "gs://kubebuilder-release/kubebuilder_master_linux_ppc64le.tar.gz"] -- name: "ubuntu" - args: ["tar", "-zcvf", "kubebuilder_darwin_amd64.tar.gz", "-C", "dist/kubebuilder_darwin_amd64_v1", "kubebuilder"] -- name: "gcr.io/cloud-builders/gsutil" - args: ["-h", "Content-Type:application/gzip", "cp", "kubebuilder_darwin_amd64.tar.gz", "gs://kubebuilder-release/kubebuilder_master_darwin_amd64.tar.gz"] -- name: "ubuntu" - args: ["tar", "-zcvf", "kubebuilder_darwin_arm64.tar.gz", "-C", "dist/kubebuilder_darwin_arm64", "kubebuilder"] -- name: "gcr.io/cloud-builders/gsutil" - args: ["-h", "Content-Type:application/gzip", "cp", "kubebuilder_darwin_arm64.tar.gz", "gs://kubebuilder-release/kubebuilder_master_darwin_arm64.tar.gz"] - -