forked from GoogleCloudPlatform/compute-image-import
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli_tools_cloudbuild.yaml
208 lines (186 loc) · 7.85 KB
/
cli_tools_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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
timeout: 14400s
options:
env:
- GO111MODULE=auto
- GOPROXY=https://proxy.golang.org
volumes:
- name: go-pkg
path: /go/pkg
- name: go-src
path: /go/src
substitutions:
_TAG: 'latest'
_RELEASE_PROJECT_FLAG: 'github.com/GoogleCloudPlatform/compute-image-import/cli_tools/common/utils/param.ReleaseProject'
_IMAGE_PROJECT_1: 'compute-image-import'
_IMAGE_PROJECT_2: 'compute-image-tools'
steps:
# Build import_precheck.
- name: 'golang'
dir: 'cli_tools/import_precheck'
args: ['go', 'build', '-o=/workspace/linux/import_precheck']
env: ['CGO_ENABLED=0']
- name: 'golang'
dir: 'cli_tools/import_precheck'
args: ['go', 'build', '-o=/workspace/windows/import_precheck.exe']
env: ['GOOS=windows']
- name: 'golang'
dir: 'cli_tools/import_precheck'
args: ['go', 'build', '-o=/workspace/linux/import_precheck_32bit']
env:
- CGO_ENABLED=0
- GOARCH=386
- name: 'golang'
dir: 'cli_tools/import_precheck'
args: ['go', 'build', '-o=/workspace/windows/import_precheck_32bit.exe']
env:
- GOOS=windows
- GOARCH=386
# Build gce_vm_image_import.
- name: 'golang'
dir: 'cli_tools/gce_vm_image_import'
args: ['go', 'build', '-o=/workspace/linux/gce_vm_image_import', '-ldflags=-X $_RELEASE_PROJECT_FLAG=$_IMAGE_PROJECT_1']
env: ['CGO_ENABLED=0']
- name: 'gcr.io/kaniko-project/executor:v1.1.0'
args:
- --destination=gcr.io/$_IMAGE_PROJECT_1/gce_vm_image_import:$_TAG
- --destination=gcr.io/$_IMAGE_PROJECT_1/gce_vm_image_import:$COMMIT_SHA
- --context=/workspace
- --dockerfile=gce_vm_image_import.Dockerfile
# Build gce_onestep_image_import.
- name: 'golang'
dir: 'cli_tools/gce_onestep_image_import'
args: ['go', 'build', '-o=/workspace/linux/gce_onestep_image_import', '-ldflags=-X $_RELEASE_PROJECT_FLAG=$_IMAGE_PROJECT_1']
env: ['CGO_ENABLED=0']
- name: 'gcr.io/kaniko-project/executor:v1.1.0'
args:
- --destination=gcr.io/$_IMAGE_PROJECT_1/gce_onestep_image_import:$_TAG
- --destination=gcr.io/$_IMAGE_PROJECT_1/gce_onestep_image_import:$COMMIT_SHA
- --context=/workspace
- --dockerfile=gce_onestep_image_import.Dockerfile
# Build gce_vm_image_export.
- name: 'golang'
dir: 'cli_tools/gce_vm_image_export'
args: ['go', 'build', '-o=/workspace/linux/gce_vm_image_export', '-ldflags=-X $_RELEASE_PROJECT_FLAG=$_IMAGE_PROJECT_1']
env: ['CGO_ENABLED=0']
- name: 'gcr.io/kaniko-project/executor:v1.1.0'
args:
- --destination=gcr.io/$_IMAGE_PROJECT_1/gce_vm_image_export:$_TAG
- --destination=gcr.io/$_IMAGE_PROJECT_1/gce_vm_image_export:$COMMIT_SHA
- --context=/workspace
- --dockerfile=gce_vm_image_export.Dockerfile
# Build gce_ovf_import.
- name: 'golang'
dir: 'cli_tools/gce_ovf_import'
args: ['go', 'build', '-o=/workspace/linux/gce_ovf_import', '-ldflags=-X $_RELEASE_PROJECT_FLAG=$_IMAGE_PROJECT_1']
env: ['CGO_ENABLED=0']
- name: 'gcr.io/kaniko-project/executor:v1.1.0'
args:
- --destination=gcr.io/$_IMAGE_PROJECT_1/gce_ovf_import:$_TAG
- --destination=gcr.io/$_IMAGE_PROJECT_1/gce_ovf_import:$COMMIT_SHA
- --context=/workspace
- --dockerfile=gce_ovf_import.Dockerfile
# Build gce_ovf_export.
- name: 'golang'
dir: 'cli_tools/gce_ovf_export'
args: ['go', 'build', '-o=/workspace/linux/gce_ovf_export', '-ldflags=-X $_RELEASE_PROJECT_FLAG=$_IMAGE_PROJECT_1']
env: ['CGO_ENABLED=0']
- name: 'gcr.io/kaniko-project/executor:v1.1.0'
args:
- --destination=gcr.io/$_IMAGE_PROJECT_1/gce_ovf_export:$_TAG
- --destination=gcr.io/$_IMAGE_PROJECT_1/gce_ovf_export:$COMMIT_SHA
- --context=/workspace
- --dockerfile=gce_ovf_export.Dockerfile
# Copy Linux binaries to GCS
- name: 'gcr.io/cloud-builders/gsutil'
args: ['cp', '/workspace/linux/*', 'gs://$_IMAGE_PROJECT_1/$_TAG/linux/']
# Copy Windows binaries to GCS
- name: 'gcr.io/cloud-builders/gsutil'
args: ['cp', '/workspace/windows/*', 'gs://$_IMAGE_PROJECT_1/$_TAG/windows/']
# IMAGE_PROJECT_2 specific binaries
# Build gce_vm_image_import.
- name: 'golang'
dir: 'cli_tools/gce_vm_image_import'
args: ['go', 'build', '-o=/workspace/linux/gce_vm_image_import', '-ldflags=-X $_RELEASE_PROJECT_FLAG=$_IMAGE_PROJECT_2']
env: ['CGO_ENABLED=0']
- name: 'gcr.io/kaniko-project/executor:v1.1.0'
args:
- --destination=gcr.io/$_IMAGE_PROJECT_2/gce_vm_image_import:$_TAG
- --destination=gcr.io/$_IMAGE_PROJECT_2/gce_vm_image_import:$COMMIT_SHA
- --context=/workspace
- --dockerfile=gce_vm_image_import.Dockerfile
# Build gce_onestep_image_import.
- name: 'golang'
dir: 'cli_tools/gce_onestep_image_import'
args: ['go', 'build', '-o=/workspace/linux/gce_onestep_image_import', '-ldflags=-X $_RELEASE_PROJECT_FLAG=$_IMAGE_PROJECT_2']
env: ['CGO_ENABLED=0']
- name: 'gcr.io/kaniko-project/executor:v1.1.0'
args:
- --destination=gcr.io/$_IMAGE_PROJECT_2/gce_onestep_image_import:$_TAG
- --destination=gcr.io/$_IMAGE_PROJECT_2/gce_onestep_image_import:$COMMIT_SHA
- --context=/workspace
- --dockerfile=gce_onestep_image_import.Dockerfile
# Build gce_vm_image_export.
- name: 'golang'
dir: 'cli_tools/gce_vm_image_export'
args: ['go', 'build', '-o=/workspace/linux/gce_vm_image_export', '-ldflags=-X $_RELEASE_PROJECT_FLAG=$_IMAGE_PROJECT_2']
env: ['CGO_ENABLED=0']
- name: 'gcr.io/kaniko-project/executor:v1.1.0'
args:
- --destination=gcr.io/$_IMAGE_PROJECT_2/gce_vm_image_export:$_TAG
- --destination=gcr.io/$_IMAGE_PROJECT_2/gce_vm_image_export:$COMMIT_SHA
- --context=/workspace
- --dockerfile=gce_vm_image_export.Dockerfile
# Build gce_ovf_import.
- name: 'golang'
dir: 'cli_tools/gce_ovf_import'
args: ['go', 'build', '-o=/workspace/linux/gce_ovf_import', '-ldflags=-X $_RELEASE_PROJECT_FLAG=$_IMAGE_PROJECT_2']
env: ['CGO_ENABLED=0']
- name: 'gcr.io/kaniko-project/executor:v1.1.0'
args:
- --destination=gcr.io/$_IMAGE_PROJECT_2/gce_ovf_import:$_TAG
- --destination=gcr.io/$_IMAGE_PROJECT_2/gce_ovf_import:$COMMIT_SHA
- --context=/workspace
- --dockerfile=gce_ovf_import.Dockerfile
# Build gce_ovf_export.
- name: 'golang'
dir: 'cli_tools/gce_ovf_export'
args: ['go', 'build', '-o=/workspace/linux/gce_ovf_export', '-ldflags=-X $_RELEASE_PROJECT_FLAG=$_IMAGE_PROJECT_2']
env: ['CGO_ENABLED=0']
- name: 'gcr.io/kaniko-project/executor:v1.1.0'
args:
- --destination=gcr.io/$_IMAGE_PROJECT_2/gce_ovf_export:$_TAG
- --destination=gcr.io/$_IMAGE_PROJECT_2/gce_ovf_export:$COMMIT_SHA
- --context=/workspace
- --dockerfile=gce_ovf_export.Dockerfile
# Copy Linux binaries to GCS - (To be deleted after fully moved to compute-image-import project)
- name: 'gcr.io/cloud-builders/gsutil'
args: ['cp', '/workspace/linux/*', 'gs://$_IMAGE_PROJECT_2/$_TAG/linux/']
# Copy Windows binaries to GCS - (To be deleted after fully moved to compute-image-import project)
- name: 'gcr.io/cloud-builders/gsutil'
args: ['cp', '/workspace/windows/*', 'gs://$_IMAGE_PROJECT_2/$_TAG/windows/']
# Push Wrappers to all the Artifact Registry regions
- name: 'google/cloud-sdk:alpine'
args:
- 'bash'
- '-c'
- |
GCP_PROJECTS=($_IMAGE_PROJECT_1 $_IMAGE_PROJECT_2)
REGIONS=()
readarray -t REGIONS < ./supported-regions
TOOLS=("gce_vm_image_import" "gce_onestep_image_import" "gce_vm_image_export" "gce_ovf_import" "gce_ovf_export")
for _PROJECT in ${GCP_PROJECTS[@]}
do
for _REGION in ${REGIONS[@]}
do
for _TOOL in ${TOOLS[@]}
do
echo "--> Deploying... $$_TOOL -> $$_REGION in $$_PROJECT project."
gcloud container images add-tag gcr.io/$$_PROJECT/$$_TOOL:$_TAG $$_REGION-docker.pkg.dev/$$_PROJECT/wrappers/$$_TOOL:$_TAG -q
gcloud container images add-tag gcr.io/$$_PROJECT/$$_TOOL:$COMMIT_SHA $$_REGION-docker.pkg.dev/$$_PROJECT/wrappers/$$_TOOL:$COMMIT_SHA -q
done
done
echo "----> Deployed all tools for all regions in $$_PROJECT project"
done
# Make binaries world-readable (To be deleted after fully moved to compute-image-import project).
- name: 'gcr.io/cloud-builders/gsutil'
args: ['-m', 'acl', '-r', 'ch', '-u', 'AllUsers:R', 'gs://$_IMAGE_PROJECT_2/$_TAG/*']