forked from GoogleCloudPlatform/compute-image-import
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcli_tools_cloudbuild.yaml
More file actions
134 lines (120 loc) · 4.63 KB
/
cli_tools_cloudbuild.yaml
File metadata and controls
134 lines (120 loc) · 4.63 KB
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
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: 'compute-image-import'
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']
env: ['CGO_ENABLED=0']
- name: 'gcr.io/kaniko-project/executor:v1.1.0'
args:
- --destination=gcr.io/$_IMAGE_PROJECT/gce_vm_image_import:$_TAG
- --destination=gcr.io/$_IMAGE_PROJECT/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']
env: ['CGO_ENABLED=0']
- name: 'gcr.io/kaniko-project/executor:v1.1.0'
args:
- --destination=gcr.io/$_IMAGE_PROJECT/gce_onestep_image_import:$_TAG
- --destination=gcr.io/$_IMAGE_PROJECT/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']
env: ['CGO_ENABLED=0']
- name: 'gcr.io/kaniko-project/executor:v1.1.0'
args:
- --destination=gcr.io/$_IMAGE_PROJECT/gce_vm_image_export:$_TAG
- --destination=gcr.io/$_IMAGE_PROJECT/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']
env: ['CGO_ENABLED=0']
- name: 'gcr.io/kaniko-project/executor:v1.1.0'
args:
- --destination=gcr.io/$_IMAGE_PROJECT/gce_ovf_import:$_TAG
- --destination=gcr.io/$_IMAGE_PROJECT/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']
env: ['CGO_ENABLED=0']
- name: 'gcr.io/kaniko-project/executor:v1.1.0'
args:
- --destination=gcr.io/$_IMAGE_PROJECT/gce_ovf_export:$_TAG
- --destination=gcr.io/$_IMAGE_PROJECT/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/$_TAG/linux/']
# Copy Windows binaries to GCS
- name: 'gcr.io/cloud-builders/gsutil'
args: ['cp', '/workspace/windows/*', 'gs://$_IMAGE_PROJECT/$_TAG/windows/']
# Push Wrappers to all the Artifact Registry regions
- name: 'google/cloud-sdk:alpine'
args:
- 'bash'
- '-c'
- |
GCP_PROJECTS=($_IMAGE_PROJECT)
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