forked from kubernetes-sigs/hierarchical-namespaces
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudbuild.yaml
106 lines (105 loc) · 3.57 KB
/
cloudbuild.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
steps:
# Build release container image
# Pull source and check out correct tag
- name: gcr.io/cloud-builders/git
entrypoint: 'bash'
args:
- '-c'
- |
set -e
echo Cloning from https://github.com/$_HNC_REPO_OWNER/hierarchical-namespaces
git clone https://github.com/$_HNC_REPO_OWNER/hierarchical-namespaces
cd hierarchical-namespaces
echo Checking out $_HNC_IMG_TAG
git checkout $_HNC_IMG_TAG
# Build the manifests and the kubectl plugin
- name: golang:1.17
entrypoint: 'bash'
args:
- '-c'
- |
set -e
cd hierarchical-namespaces
export HNC_REGISTRY=$_HNC_REGISTRY
export HNC_IMG_NAME=$_HNC_IMG_NAME
export HNC_IMG_TAG=$_HNC_IMG_TAG
export HNC_RELEASE_REPO_OWNER=$_HNC_REPO_OWNER
echo "Building HNC manifests and plugin for $$HNC_REGISTRY/$$HNC_IMG_NAME:$$HNC_IMG_TAG"
make build
make krew-build
# Upload manifest
- name: gcr.io/cloud-builders/curl
args:
- '-X'
- 'POST'
- '-H'
- 'Content-Type: application/x-application'
- '--data-binary'
- '@hierarchical-namespaces/manifests/hnc-manager.yaml'
- '-u'
- '$_HNC_USER:$_HNC_PERSONAL_ACCESS_TOKEN'
- 'https://uploads.github.com/repos/$_HNC_REPO_OWNER/hierarchical-namespaces/releases/$_HNC_RELEASE_ID/assets?name=hnc-manager.yaml'
# Upload plugin (Linux)
- name: gcr.io/cloud-builders/curl
args:
- '-X'
- 'POST'
- '-H'
- 'Content-Type: application/x-application'
- '--data-binary'
- '@hierarchical-namespaces/bin/kubectl/kubectl-hns_linux_amd64'
- '-u'
- '$_HNC_USER:$_HNC_PERSONAL_ACCESS_TOKEN'
- 'https://uploads.github.com/repos/$_HNC_REPO_OWNER/hierarchical-namespaces/releases/$_HNC_RELEASE_ID/assets?name=kubectl-hns_linux_amd64'
# Upload plugin (Darwin)
- name: gcr.io/cloud-builders/curl
args:
- '-X'
- 'POST'
- '-H'
- 'Content-Type: application/x-application'
- '--data-binary'
- '@hierarchical-namespaces/bin/kubectl/kubectl-hns_darwin_amd64'
- '-u'
- '$_HNC_USER:$_HNC_PERSONAL_ACCESS_TOKEN'
- 'https://uploads.github.com/repos/$_HNC_REPO_OWNER/hierarchical-namespaces/releases/$_HNC_RELEASE_ID/assets?name=kubectl-hns_darwin_amd64'
# Upload plugin (Windows)
- name: gcr.io/cloud-builders/curl
args:
- '-X'
- 'POST'
- '-H'
- 'Content-Type: application/x-application'
- '--data-binary'
- '@hierarchical-namespaces/bin/kubectl/kubectl-hns_windows_amd64.exe'
- '-u'
- '$_HNC_USER:$_HNC_PERSONAL_ACCESS_TOKEN'
- 'https://uploads.github.com/repos/$_HNC_REPO_OWNER/hierarchical-namespaces/releases/$_HNC_RELEASE_ID/assets?name=kubectl-hns_windows_amd64.exe'
# Upload plugin (Krew tar file)
- name: gcr.io/cloud-builders/curl
args:
- '-X'
- 'POST'
- '-H'
- 'Content-Type: application/x-application'
- '--data-binary'
- '@hierarchical-namespaces/bin/kubectl-hns.tar.gz'
- '-u'
- '$_HNC_USER:$_HNC_PERSONAL_ACCESS_TOKEN'
- 'https://uploads.github.com/repos/$_HNC_REPO_OWNER/hierarchical-namespaces/releases/$_HNC_RELEASE_ID/assets?name=kubectl-hns.tar.gz'
# Upload plugin (Krew manifest file - to add to the Krew index)
- name: gcr.io/cloud-builders/curl
args:
- '-X'
- 'POST'
- '-H'
- 'Content-Type: application/x-application'
- '--data-binary'
- '@hierarchical-namespaces/manifests/krew-kubectl-hns.yaml'
- '-u'
- '$_HNC_USER:$_HNC_PERSONAL_ACCESS_TOKEN'
- 'https://uploads.github.com/repos/$_HNC_REPO_OWNER/hierarchical-namespaces/releases/$_HNC_RELEASE_ID/assets?name=krew-kubectl-hns.yaml'
# Build Docker image
- name: gcr.io/cloud-builders/docker
args: ['build', '-t', 'gcr.io/$PROJECT_ID/$_HNC_IMG_NAME:$_HNC_IMG_TAG', 'hierarchical-namespaces']
images: ['gcr.io/$PROJECT_ID/$_HNC_IMG_NAME:$_HNC_IMG_TAG']