Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 65b24c7

Browse files
authoredMay 21, 2018
Merge pull request kubernetes-sigs#21 from droot/update-release-scripts
updated release scripts for kustomize
2 parents 2aa3fea + 284f9cd commit 65b24c7

6 files changed

+70
-54
lines changed
 

‎build/.goreleaser.yml

-29
This file was deleted.

‎build/README.md

+8-11
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
## Steps to run build locally
1+
## Overview
22

3-
Install container-builder-local from github and define GOOS, GOARCH, OUTPUT env
4-
variables and run following command
3+
This directory contains scripts and configruation files for publishing a
4+
`kustomize` release on [release page](https://github.com/kubernetes-sigs/kustomize/releases)
5+
6+
## Steps to run build a release locally
7+
Install container-builder-local from [github](https://github.com/GoogleCloudPlatform/container-builder-local).
58

69
```sh
7-
container-builder-local --config=cmd/kustomize/build/cloudbuild_local.yaml --dryrun=false --substitutions=_GOOS=$GOOS,_GOARCH=$GOARCH --write-workspace=$OUTPUT .
10+
container-builder-local --config=build/cloudbuild_local.yaml --dryrun=false --write-workspace=/tmp/w .
811
```
912

10-
## Steps to submit build to Google container builder
11-
12-
You need to be at the repo level to be able to run the following command
13-
14-
```
15-
gcloud container builds submit . --config=cmd/kustomize/build/cloudbuild.yaml --substitutions=_GOOS=$GOOS,_GOARCH=$GOARCH
16-
```
13+
You will find the build artifacts under `/tmp/w/dist` directory

‎build/build.sh

+25-8
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,37 @@ set -x
2323
# - Use /go as the default GOPATH because this is what the image uses
2424
# - Link our current directory (containing the source code) to the package location in the GOPATH
2525

26-
export PKG=k8s.io
27-
export REPO=kubectl
28-
export CMD=kustomize
26+
OWNER="kubernetes-sigs"
27+
REPO="kustomize"
2928

30-
GO_PKG_OWNER=$GOPATH/src/$PKG
29+
GO_PKG_OWNER=$GOPATH/src/github.com/$OWNER
3130
GO_PKG_PATH=$GO_PKG_OWNER/$REPO
3231

3332
mkdir -p $GO_PKG_OWNER
34-
ln -s $(pwd) $GO_PKG_PATH
33+
ln -sf $(pwd) $GO_PKG_PATH
3534

3635
# When invoked in container builder, this script runs under /workspace which is
3736
# not under $GOPATH, so we need to `cd` to repo under GOPATH for it to build
3837
cd $GO_PKG_PATH
3938

40-
/goreleaser release --config=cmd/$CMD/build/.goreleaser.yml --debug --rm-dist
41-
# --skip-validate
42-
# --snapshot --skip-publish
39+
40+
# NOTE: if snapshot is enabled, release is not published to GitHub and the build
41+
# is available under workspace/dist directory.
42+
SNAPSHOT=""
43+
44+
# parse commandline args copied from the link below
45+
# 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
46+
47+
while [[ $# -gt 0 ]]
48+
do
49+
key="$1"
50+
51+
case $key in
52+
--snapshot)
53+
SNAPSHOT="--snapshot"
54+
shift # past argument
55+
;;
56+
esac
57+
done
58+
59+
/goreleaser release --config=build/goreleaser.yml --rm-dist --skip-validate ${SNAPSHOT}

‎build/cloudbuild.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
# TODO(droot): add instructions for running in production.
1616
steps:
17-
- name: "ubuntu"
18-
args: ["mkdir", "-p", "/workspace/_output"]
17+
- name: "gcr.io/cloud-builders/git"
18+
args: [fetch, --tags, --depth=100]
1919
- name: "gcr.io/kustomize-199618/golang_with_goreleaser:1.10-stretch"
20-
args: ["bash", "cmd/kustomize/build/build.sh"]
20+
args: ["bash", "build/build.sh"]
2121
secretEnv: ['GITHUB_TOKEN']
2222
secrets:
2323
- kmsKeyName: projects/kustomize-199618/locations/global/keyRings/github-tokens/cryptoKeys/gh-release-token

‎build/cloudbuild_local.yaml

+1-3
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@
2121
# Release tar will be in $OUTPUT
2222

2323
steps:
24-
- name: "ubuntu"
25-
args: ["mkdir", "-p", "/workspace/_output"]
2624
- name: "gcr.io/kustomize-199618/golang_with_goreleaser:1.10-stretch"
27-
args: ["bash", "cmd/kustomize/build/build.sh"]
25+
args: ["bash", "build/build.sh", "--snapshot"]
2826
secretEnv: ['GITHUB_TOKEN']
2927
secrets:
3028
- kmsKeyName: projects/kustomize-199618/locations/global/keyRings/github-tokens/cryptoKeys/gh-release-token

‎build/goreleaser.yaml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# This is an example goreleaser.yaml file with some sane defaults.
2+
# Make sure to check the documentation at http://goreleaser.com
3+
project_name: kustomize
4+
builds:
5+
- main: ./kustomize.go
6+
binary: kustomize
7+
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}}
8+
goos:
9+
- darwin
10+
- linux
11+
- windows
12+
goarch:
13+
- amd64
14+
env:
15+
- CGO_ENABLED=0
16+
checksum:
17+
name_template: 'checksums.txt'
18+
archive:
19+
format: binary
20+
snapshot:
21+
name_template: "master"
22+
changelog:
23+
sort: asc
24+
filters:
25+
exclude:
26+
- '^docs:'
27+
- '^test:'
28+
- Merge pull request
29+
- Merge branch
30+
release:
31+
github:
32+
owner: kubernetes-sigs
33+
name: kustomize

0 commit comments

Comments
 (0)
Please sign in to comment.