mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-10 16:42:51 +00:00
Use go modules in cloud builder.
This commit is contained in:
@@ -10,12 +10,10 @@ Scripts and configuration files for publishing a
|
|||||||
Install [`cloud-build-local`], then run
|
Install [`cloud-build-local`], then run
|
||||||
|
|
||||||
```
|
```
|
||||||
cloud-build-local \
|
./build/localbuild.sh
|
||||||
--config=build/cloudbuild_local.yaml \
|
|
||||||
--dryrun=false --write-workspace=/tmp/w .
|
|
||||||
```
|
```
|
||||||
|
|
||||||
to build artifacts under `/tmp/w/dist`.
|
to build artifacts under `./dist`.
|
||||||
|
|
||||||
### Publish a Release
|
### Publish a Release
|
||||||
|
|
||||||
|
|||||||
@@ -1,27 +1,22 @@
|
|||||||
#!/bin/bash
|
#!/bin/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.
|
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
# Google Container Builder automatically checks out all the code under the /workspace directory,
|
# Google Container Builder automatically checks
|
||||||
# but we actually want it to under the correct expected package in the GOPATH (/go)
|
# out all the code under the /workspace directory,
|
||||||
# - Create the directory to host the code that matches the expected GOPATH package locations
|
# but we actually want it to under the correct
|
||||||
# - Use /go as the default GOPATH because this is what the image uses
|
# expected package in the GOPATH (/go)
|
||||||
# - Link our current directory (containing the source code) to the package location in the GOPATH
|
#
|
||||||
|
# - Create the directory to host the code that
|
||||||
|
# matches the expected GOPATH package locations
|
||||||
|
#
|
||||||
|
# - 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
|
||||||
|
|
||||||
OWNER="sigs.k8s.io"
|
OWNER="sigs.k8s.io"
|
||||||
REPO="kustomize"
|
REPO="kustomize"
|
||||||
@@ -37,13 +32,14 @@ ln -sf $(pwd) $GO_PKG_PATH
|
|||||||
cd $GO_PKG_PATH
|
cd $GO_PKG_PATH
|
||||||
|
|
||||||
|
|
||||||
# NOTE: if snapshot is enabled, release is not published to GitHub and the build
|
# If snapshot is enabled, release is not published
|
||||||
# is available under workspace/dist directory.
|
# to GitHub and the build is available under
|
||||||
|
# workspace/dist directory.
|
||||||
|
|
||||||
SNAPSHOT=""
|
SNAPSHOT=""
|
||||||
|
|
||||||
# parse commandline args copied from the link below
|
# 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
|
# 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 ]]
|
while [[ $# -gt 0 ]]
|
||||||
do
|
do
|
||||||
key="$1"
|
key="$1"
|
||||||
@@ -56,4 +52,8 @@ case $key in
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
/goreleaser release --config=build/goreleaser.yaml --rm-dist --skip-validate ${SNAPSHOT}
|
/goreleaser \
|
||||||
|
release \
|
||||||
|
--config=build/goreleaser.yaml \
|
||||||
|
--rm-dist \
|
||||||
|
--skip-validate ${SNAPSHOT}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
steps:
|
steps:
|
||||||
- name: "gcr.io/cloud-builders/git"
|
- name: "gcr.io/cloud-builders/git"
|
||||||
args: [fetch, --tags, --depth=100]
|
args: [fetch, --tags, --depth=100]
|
||||||
- name: "gcr.io/kustomize-199618/golang_with_goreleaser:1.10-stretch"
|
- name: "gcr.io/kubebuilder/goreleaser_with_go_1.12.5:0.0.1"
|
||||||
args: ["bash", "build/cloudbuild.sh"]
|
args: ["bash", "build/cloudbuild.sh"]
|
||||||
secretEnv: ['GITHUB_TOKEN']
|
secretEnv: ['GITHUB_TOKEN']
|
||||||
secrets:
|
secrets:
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
# This is an example goreleaser.yaml file with some sane defaults.
|
# Documentation at http://goreleaser.com
|
||||||
# Make sure to check the 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
|
project_name: kustomize
|
||||||
builds:
|
builds:
|
||||||
- main: ./kustomize.go
|
- main: ./kustomize.go
|
||||||
@@ -8,11 +12,11 @@ builds:
|
|||||||
goos:
|
goos:
|
||||||
- darwin
|
- darwin
|
||||||
- linux
|
- linux
|
||||||
- windows
|
|
||||||
goarch:
|
goarch:
|
||||||
- amd64
|
- amd64
|
||||||
env:
|
env:
|
||||||
- CGO_ENABLED=0
|
- CGO_ENABLED=0
|
||||||
|
- GO111MODULE=on
|
||||||
checksum:
|
checksum:
|
||||||
name_template: 'checksums.txt'
|
name_template: 'checksums.txt'
|
||||||
archive:
|
archive:
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
# The script attempts to use cloudbuild configuration
|
# The script attempts to use cloudbuild configuration
|
||||||
# to create a release "locally".
|
# to create a release "locally".
|
||||||
#
|
#
|
||||||
|
# See https://cloud.google.com/cloud-build/docs/build-debug-locally
|
||||||
|
#
|
||||||
# At the time of writing,
|
# At the time of writing,
|
||||||
#
|
#
|
||||||
# https://pantheon.corp.google.com/cloud-build/triggers?project=kustomize-199618
|
# https://pantheon.corp.google.com/cloud-build/triggers?project=kustomize-199618
|
||||||
@@ -25,23 +27,23 @@
|
|||||||
# analogous via docker tricks.
|
# analogous via docker tricks.
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
# set -x
|
|
||||||
|
|
||||||
if [ -z ${GOPATH+x} ]; then
|
if [ -z ${GOPATH+x} ]; then
|
||||||
echo GOPATH is unset; cannot proceed.
|
echo GOPATH is unset; cannot proceed.
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
WORK=$(mktemp -d)
|
|
||||||
|
|
||||||
pushd $GOPATH/src/sigs.k8s.io/kustomize
|
pushd $GOPATH/src/sigs.k8s.io/kustomize
|
||||||
pwd
|
pwd
|
||||||
|
|
||||||
echo "Building in $WORK"
|
# The first "step" in the following uses a special
|
||||||
|
# goreleaser container image that the kubebuilder folks made.
|
||||||
|
# TODO: On a rainy day, switch to something more standard.
|
||||||
|
|
||||||
cat <<EOF >/tmp/localbuild.yaml
|
config=$(mktemp)
|
||||||
|
cat <<EOF >$config
|
||||||
steps:
|
steps:
|
||||||
- name: "gcr.io/kustomize-199618/golang_with_goreleaser:1.10-stretch"
|
- name: "gcr.io/kubebuilder/goreleaser_with_go_1.12.5:0.0.1"
|
||||||
args: ["bash", "build/cloudbuild.sh", "--snapshot"]
|
args: ["bash", "build/cloudbuild.sh", "--snapshot"]
|
||||||
secretEnv: ['GITHUB_TOKEN']
|
secretEnv: ['GITHUB_TOKEN']
|
||||||
secrets:
|
secrets:
|
||||||
@@ -50,18 +52,15 @@ secrets:
|
|||||||
GITHUB_TOKEN: CiQAyrREbPgXJOeT7M3t+WlxkhXwlMPudixBeiyWTjmLOMLqdK4SUQA0W+xUmDJKAhyfHCcwqSEzUn9OwKC7XAYcmwe0CCKTCbPbDgmioDK24q3LVapndXNvnnHvCjhOJNEr1o+P1DCF+LlzYV2YL8lP09rrKrslPg==
|
GITHUB_TOKEN: CiQAyrREbPgXJOeT7M3t+WlxkhXwlMPudixBeiyWTjmLOMLqdK4SUQA0W+xUmDJKAhyfHCcwqSEzUn9OwKC7XAYcmwe0CCKTCbPbDgmioDK24q3LVapndXNvnnHvCjhOJNEr1o+P1DCF+LlzYV2YL8lP09rrKrslPg==
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# --substitutions=_GOOS=linux,_GOARCH=amd64
|
|
||||||
|
|
||||||
config=build/cloudbuild.yaml
|
|
||||||
config=/tmp/localbuild.yaml
|
|
||||||
|
|
||||||
# See https://cloud.google.com/cloud-build/docs/build-debug-locally
|
|
||||||
cloud-build-local \
|
cloud-build-local \
|
||||||
--config=$config \
|
--config=$config \
|
||||||
|
--bind-mount-source \
|
||||||
--dryrun=false \
|
--dryrun=false \
|
||||||
--write-workspace=$WORK \
|
|
||||||
.
|
.
|
||||||
|
|
||||||
tree $WORK
|
# Print results of local build, which went to ./dist
|
||||||
|
echo "##########################################"
|
||||||
|
tree ./dist
|
||||||
|
echo "##########################################"
|
||||||
|
|
||||||
popd
|
popd
|
||||||
|
|||||||
Reference in New Issue
Block a user