Skip to content

Commit

Permalink
updated release scripts for kustomize
Browse files Browse the repository at this point in the history
  • Loading branch information
droot committed May 21, 2018
1 parent 314e66a commit 284f9cd
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 54 deletions.
29 changes: 0 additions & 29 deletions build/.goreleaser.yml

This file was deleted.

19 changes: 8 additions & 11 deletions build/README.md
Original file line number Diff line number Diff line change
@@ -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
33 changes: 25 additions & 8 deletions build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
6 changes: 3 additions & 3 deletions build/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions build/cloudbuild_local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 33 additions & 0 deletions build/goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http:https://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

0 comments on commit 284f9cd

Please sign in to comment.