diff --git a/build/.goreleaser.yml b/build/.goreleaser.yml deleted file mode 100644 index fc91ac734..000000000 --- a/build/.goreleaser.yml +++ /dev/null @@ -1,29 +0,0 @@ -# This is an example goreleaser.yaml file with some sane defaults. -# Make sure to check the documentation at http://goreleaser.com -project_name: kustomize -builds: -- main: ./cmd/kustomize - binary: kustomize - ldflags: -s -X k8s.io/kubectl/cmd/kustomize/version.kustomizeVersion={{.Version}} -X k8s.io/kubectl/cmd/kustomize/version.gitCommit={{.Commit}} -X k8s.io/kubectl/cmd/kustomize/version.buildDate={{.Date}} - goos: - - darwin - - linux - - windows - env: - - CGO_ENABLED=0 -archive: - wrap_in_directory: true -checksum: - name_template: 'checksums.txt' -snapshot: - name_template: "{{ .Tag }}-next" -changelog: - sort: asc - filters: - exclude: - - '^docs:' - - '^test:' -release: - github: - owner: droot - name: kubectl diff --git a/build/README.md b/build/README.md index 95ba60c79..411b9c752 100644 --- a/build/README.md +++ b/build/README.md @@ -1,16 +1,13 @@ -## Steps to run build locally +## Overview -Install container-builder-local from github and define GOOS, GOARCH, OUTPUT env -variables and run following command +This directory contains scripts and configruation files for publishing a +`kustomize` release on [release page](https://github.com/kubernetes-sigs/kustomize/releases) + +## Steps to run build a release locally +Install container-builder-local from [github](https://github.com/GoogleCloudPlatform/container-builder-local). ```sh -container-builder-local --config=cmd/kustomize/build/cloudbuild_local.yaml --dryrun=false --substitutions=_GOOS=$GOOS,_GOARCH=$GOARCH --write-workspace=$OUTPUT . +container-builder-local --config=build/cloudbuild_local.yaml --dryrun=false --write-workspace=/tmp/w . ``` -## Steps to submit build to Google container builder - -You need to be at the repo level to be able to run the following command - -``` -gcloud container builds submit . --config=cmd/kustomize/build/cloudbuild.yaml --substitutions=_GOOS=$GOOS,_GOARCH=$GOARCH -``` +You will find the build artifacts under `/tmp/w/dist` directory diff --git a/build/build.sh b/build/build.sh index 1ceba94cc..e438b89ad 100755 --- a/build/build.sh +++ b/build/build.sh @@ -23,20 +23,37 @@ set -x # - Use /go as the default GOPATH because this is what the image uses # - Link our current directory (containing the source code) to the package location in the GOPATH -export PKG=k8s.io -export REPO=kubectl -export CMD=kustomize +OWNER="kubernetes-sigs" +REPO="kustomize" -GO_PKG_OWNER=$GOPATH/src/$PKG +GO_PKG_OWNER=$GOPATH/src/github.com/$OWNER GO_PKG_PATH=$GO_PKG_OWNER/$REPO mkdir -p $GO_PKG_OWNER -ln -s $(pwd) $GO_PKG_PATH +ln -sf $(pwd) $GO_PKG_PATH # When invoked in container builder, this script runs under /workspace which is # not under $GOPATH, so we need to `cd` to repo under GOPATH for it to build cd $GO_PKG_PATH -/goreleaser release --config=cmd/$CMD/build/.goreleaser.yml --debug --rm-dist -# --skip-validate -# --snapshot --skip-publish + +# NOTE: if snapshot is enabled, release is not published to GitHub and the build +# is available under workspace/dist directory. +SNAPSHOT="" + +# parse commandline args copied from the link below +# https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa + +while [[ $# -gt 0 ]] +do +key="$1" + +case $key in + --snapshot) + SNAPSHOT="--snapshot" + shift # past argument + ;; +esac +done + +/goreleaser release --config=build/goreleaser.yml --rm-dist --skip-validate ${SNAPSHOT} diff --git a/build/cloudbuild.yaml b/build/cloudbuild.yaml index 3df58ecd8..c843ecadb 100644 --- a/build/cloudbuild.yaml +++ b/build/cloudbuild.yaml @@ -14,10 +14,10 @@ # TODO(droot): add instructions for running in production. steps: -- name: "ubuntu" - args: ["mkdir", "-p", "/workspace/_output"] +- name: "gcr.io/cloud-builders/git" + args: [fetch, --tags, --depth=100] - name: "gcr.io/kustomize-199618/golang_with_goreleaser:1.10-stretch" - args: ["bash", "cmd/kustomize/build/build.sh"] + args: ["bash", "build/build.sh"] secretEnv: ['GITHUB_TOKEN'] secrets: - kmsKeyName: projects/kustomize-199618/locations/global/keyRings/github-tokens/cryptoKeys/gh-release-token diff --git a/build/cloudbuild_local.yaml b/build/cloudbuild_local.yaml index 6de58c4df..f1eb5bb2c 100644 --- a/build/cloudbuild_local.yaml +++ b/build/cloudbuild_local.yaml @@ -21,10 +21,8 @@ # Release tar will be in $OUTPUT steps: -- name: "ubuntu" - args: ["mkdir", "-p", "/workspace/_output"] - name: "gcr.io/kustomize-199618/golang_with_goreleaser:1.10-stretch" - args: ["bash", "cmd/kustomize/build/build.sh"] + args: ["bash", "build/build.sh", "--snapshot"] secretEnv: ['GITHUB_TOKEN'] secrets: - kmsKeyName: projects/kustomize-199618/locations/global/keyRings/github-tokens/cryptoKeys/gh-release-token diff --git a/build/goreleaser.yaml b/build/goreleaser.yaml new file mode 100644 index 000000000..918e687b2 --- /dev/null +++ b/build/goreleaser.yaml @@ -0,0 +1,33 @@ +# This is an example goreleaser.yaml file with some sane defaults. +# Make sure to check the documentation at http://goreleaser.com +project_name: kustomize +builds: +- main: ./kustomize.go + binary: kustomize + ldflags: -s -X github.com/kubernetes-sigs/kustomize/version.kustomizeVersion={{.Version}} -X github.com/kubernetes-sigs/kustomize/version.gitCommit={{.Commit}} -X github.com/kubernetes-sigs/kustomize/version.buildDate={{.Date}} + goos: + - darwin + - linux + - windows + goarch: + - amd64 + env: + - CGO_ENABLED=0 +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