timeout: 4500s

options:
  env:
  - GO111MODULE=auto
  - GOPROXY=https://proxy.golang.org
  volumes:
  - name: go-pkg
    path: /go/pkg
  - name: go-src
    path: /go/src

substitutions:
  _RELEASE: 'latest'

steps:

# Build gce_image_publish.
- name: 'golang'
  dir: 'cli_tools/gce_image_publish'
  args: ['go', 'build', '-o=/workspace/linux/gce_image_publish']
  env: ['CGO_ENABLED=0']
- name: 'golang'
  dir: 'cli_tools/gce_image_publish'
  args: ['go', 'build', '-o=/workspace/windows/gce_image_publish.exe']
  env: ['GOOS=windows']
- name: 'golang'
  dir: 'cli_tools/gce_image_publish'
  args: ['go', 'build', '-o=/workspace/darwin/gce_image_publish']
  env: ['GOOS=darwin']
- name: 'gcr.io/kaniko-project/executor:latest'
  args:
  - --destination=gcr.io/$PROJECT_ID/gce_image_publish:$_RELEASE
  - --destination=gcr.io/$PROJECT_ID/gce_image_publish:$COMMIT_SHA
  - --destination=gcr.io/$PROJECT_ID/gce_image_publish:public-image-$COMMIT_SHA
  - --context=/workspace
  - --dockerfile=gce_image_publish.Dockerfile

# Build gce_export.
- name: 'golang'
  dir: 'cli_tools/gce_export'
  args: ['go', 'build', '-o=/workspace/linux/gce_export']
  env: ['CGO_ENABLED=0']
- name: 'golang'
  dir: 'cli_tools/gce_export'
  args: ['go', 'build', '-o=/workspace/windows/gce_export']
  env: ['GOOS=windows']
- name: 'gcr.io/kaniko-project/executor:latest'
  args:
  - --destination=gcr.io/$PROJECT_ID/gce_export:$_RELEASE
  - --destination=gcr.io/$PROJECT_ID/gce_export:$COMMIT_SHA
  - --destination=gcr.io/$PROJECT_ID/gce_export:public-image-$COMMIT_SHA
  - --context=/workspace
  - --dockerfile=gce_export.Dockerfile

# Build gce_windows_upgrade.
- name: 'golang'
  dir: 'cli_tools/gce_windows_upgrade'
  args: ['go', 'build', '-o=/workspace/linux/gce_windows_upgrade']
  env: ['CGO_ENABLED=0']
- name: 'gcr.io/kaniko-project/executor:latest'
  args:
  - --destination=gcr.io/$PROJECT_ID/gce_windows_upgrade:$_RELEASE
  - --destination=gcr.io/$PROJECT_ID/gce_windows_upgrade:$COMMIT_SHA
  - --destination=gcr.io/$PROJECT_ID/gce_windows_upgrade:public-image-$COMMIT_SHA
  - --destination=us-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$_RELEASE
  - --destination=us-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$COMMIT_SHA
  - --destination=us-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:public-image-$COMMIT_SHA
  - --destination=us-central1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$_RELEASE
  - --destination=us-central1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$COMMIT_SHA
  - --destination=us-central1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:public-image-$COMMIT_SHA
  - --destination=us-west1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$_RELEASE
  - --destination=us-west1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$COMMIT_SHA
  - --destination=us-west1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:public-image-$COMMIT_SHA
  - --destination=us-west2-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$_RELEASE
  - --destination=us-west2-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$COMMIT_SHA
  - --destination=us-west2-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:public-image-$COMMIT_SHA
  - --destination=us-west3-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$_RELEASE
  - --destination=us-west3-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$COMMIT_SHA
  - --destination=us-west3-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:public-image-$COMMIT_SHA
  - --destination=us-west4-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$_RELEASE
  - --destination=us-west4-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$COMMIT_SHA
  - --destination=us-west4-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:public-image-$COMMIT_SHA
  - --destination=us-east1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$_RELEASE
  - --destination=us-east1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$COMMIT_SHA
  - --destination=us-east1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:public-image-$COMMIT_SHA
  - --destination=us-east4-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$_RELEASE
  - --destination=us-east4-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$COMMIT_SHA
  - --destination=us-east4-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:public-image-$COMMIT_SHA
  - --destination=northamerica-northeast1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$_RELEASE
  - --destination=northamerica-northeast1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$COMMIT_SHA
  - --destination=northamerica-northeast1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:public-image-$COMMIT_SHA
  - --destination=southamerica-east1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$_RELEASE
  - --destination=southamerica-east1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$COMMIT_SHA
  - --destination=southamerica-east1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:public-image-$COMMIT_SHA
  - --destination=europe-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$_RELEASE
  - --destination=europe-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$COMMIT_SHA
  - --destination=europe-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:public-image-$COMMIT_SHA
  - --destination=europe-north1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$_RELEASE
  - --destination=europe-north1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$COMMIT_SHA
  - --destination=europe-north1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:public-image-$COMMIT_SHA
  - --destination=europe-west1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$_RELEASE
  - --destination=europe-west1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$COMMIT_SHA
  - --destination=europe-west1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:public-image-$COMMIT_SHA
  - --destination=europe-west2-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$_RELEASE
  - --destination=europe-west2-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$COMMIT_SHA
  - --destination=europe-west2-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:public-image-$COMMIT_SHA
  - --destination=europe-west3-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$_RELEASE
  - --destination=europe-west3-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$COMMIT_SHA
  - --destination=europe-west3-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:public-image-$COMMIT_SHA
  - --destination=europe-west4-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$_RELEASE
  - --destination=europe-west4-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$COMMIT_SHA
  - --destination=europe-west4-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:public-image-$COMMIT_SHA
  - --destination=europe-west6-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$_RELEASE
  - --destination=europe-west6-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$COMMIT_SHA
  - --destination=europe-west6-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:public-image-$COMMIT_SHA
  - --destination=asia-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$_RELEASE
  - --destination=asia-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$COMMIT_SHA
  - --destination=asia-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:public-image-$COMMIT_SHA
  - --destination=asia-east1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$_RELEASE
  - --destination=asia-east1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$COMMIT_SHA
  - --destination=asia-east1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:public-image-$COMMIT_SHA
  - --destination=asia-east2-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$_RELEASE
  - --destination=asia-east2-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$COMMIT_SHA
  - --destination=asia-east2-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:public-image-$COMMIT_SHA
  - --destination=asia-northeast1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$_RELEASE
  - --destination=asia-northeast1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$COMMIT_SHA
  - --destination=asia-northeast1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:public-image-$COMMIT_SHA
  - --destination=asia-northeast2-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$_RELEASE
  - --destination=asia-northeast2-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$COMMIT_SHA
  - --destination=asia-northeast2-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:public-image-$COMMIT_SHA
  - --destination=asia-northeast3-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$_RELEASE
  - --destination=asia-northeast3-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$COMMIT_SHA
  - --destination=asia-northeast3-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:public-image-$COMMIT_SHA
  - --destination=asia-south1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$_RELEASE
  - --destination=asia-south1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$COMMIT_SHA
  - --destination=asia-south1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:public-image-$COMMIT_SHA
  - --destination=asia-southeast1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$_RELEASE
  - --destination=asia-southeast1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$COMMIT_SHA
  - --destination=asia-southeast1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:public-image-$COMMIT_SHA
  - --destination=asia-southeast2-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$_RELEASE
  - --destination=asia-southeast2-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$COMMIT_SHA
  - --destination=asia-southeast2-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:public-image-$COMMIT_SHA
  - --destination=australia-southeast1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$_RELEASE
  - --destination=australia-southeast1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:$COMMIT_SHA
  - --destination=australia-southeast1-docker.pkg.dev/$PROJECT_ID/wrappers/gce_windows_upgrade:public-image-$COMMIT_SHA
  - --context=/workspace
  - --dockerfile=gce_windows_upgrade.Dockerfile

# Copy Linux binaries to GCS
- name: 'gcr.io/cloud-builders/gsutil'
  args: ['cp', '/workspace/linux/*', 'gs://$PROJECT_ID/$_RELEASE/linux/']

# Copy Windows binaries to GCS
- name: 'gcr.io/cloud-builders/gsutil'
  args: ['cp', '/workspace/windows/*', 'gs://$PROJECT_ID/$_RELEASE/windows/']

# Copy OSX binaries to GCS
- name: 'gcr.io/cloud-builders/gsutil'
  args: ['cp', '/workspace/darwin/*', 'gs://$PROJECT_ID/$_RELEASE/darwin/']

# Make binaries world-readable.
- name: 'gcr.io/cloud-builders/gsutil'
  args: ['-m', 'acl', '-r', 'ch', '-u', 'AllUsers:R', 'gs://$PROJECT_ID/$_RELEASE/*']
