# In this directory, run the following command to build this builder.
# $ gcloud builds submit

steps:
# Build all supported versions.
- name: 'gcr.io/cloud-builders/docker'
  args:
  - 'build'
  - '--build-arg=NODE_VERSION=8.12.0'
  - '--tag=gcr.io/$PROJECT_ID/yarn:node-8.12.0'

  - '.'
- name: 'gcr.io/cloud-builders/docker'
  args:
  - 'build'
  - '--build-arg=NODE_VERSION=8.4.0'
  - '--tag=gcr.io/$PROJECT_ID/yarn:node-8.4.0'

  - '.'
- name: 'gcr.io/cloud-builders/docker'
  args:
  - 'build'
  - '--build-arg=NODE_VERSION=9.11.2'
  - '--tag=gcr.io/$PROJECT_ID/yarn:node-9.11.2'

  - '.'
- name: 'gcr.io/cloud-builders/docker'
  args:
  - 'build'
  - '--build-arg=NODE_VERSION=10.10.0'
  - '--tag=gcr.io/$PROJECT_ID/yarn:node-10.10.0'

  - '.'
- name: 'gcr.io/cloud-builders/docker'
  args:
  - 'build'
  - '--build-arg=NODE_VERSION=12.18.3'
  - '--tag=gcr.io/$PROJECT_ID/yarn:node-12.18.3'
  - '--tag=gcr.io/$PROJECT_ID/nodejs/yarn'

  - '.'
- name: 'gcr.io/cloud-builders/docker'
  args:
  - 'build'
  - '--build-arg=NODE_VERSION=14.10.0'
  - '--tag=gcr.io/$PROJECT_ID/yarn:node-14.10.0'
  - '.'
- name: 'gcr.io/cloud-builders/docker'
  args:
  - 'build'
  - '--build-arg=NODE_VERSION=14.17.1'
  - '--tag=gcr.io/$PROJECT_ID/yarn:node-14.17.1'
  - '--tag=gcr.io/$PROJECT_ID/yarn:latest'
  - '--tag=gcr.io/$PROJECT_ID/yarn:current'
  - '.'
- name: 'gcr.io/cloud-builders/docker'
  args:
  - 'build'
  - '--build-arg=NODE_VERSION=18.12.0'
  - '--tag=gcr.io/$PROJECT_ID/yarn:node-18.12.0'
  - '.'
- name: 'gcr.io/cloud-builders/docker'
  args:
  - 'build'
  - '--build-arg=NODE_VERSION=19.0.0'
  - '--tag=gcr.io/$PROJECT_ID/yarn:node-19.0.0'
  - '.'
- name: 'gcr.io/cloud-builders/docker'
  args:
  - 'build'
  - '--build-arg=NODE_VERSION=20.11.0'
  - '--tag=gcr.io/$PROJECT_ID/yarn:node-20.11.0'
  - '--tag=gcr.io/$PROJECT_ID/yarn:lts'
  - '.'

# Print for each version
- name: 'gcr.io/$PROJECT_ID/yarn:node-8.12.0'
  args: ['--version']
- name: 'gcr.io/$PROJECT_ID/yarn:node-8.4.0'
  args: ['--version']
- name: 'gcr.io/$PROJECT_ID/yarn:node-9.11.2'
  args: ['--version']
- name: 'gcr.io/$PROJECT_ID/yarn:node-10.10.0'
  args: ['--version']
- name: 'gcr.io/$PROJECT_ID/yarn:node-12.18.3'
  args: ['--version']
- name: 'gcr.io/$PROJECT_ID/yarn:node-14.10.0'
  args: ['--version']
- name: 'gcr.io/$PROJECT_ID/yarn:node-14.17.1'
  args: ['--version']
- name: 'gcr.io/$PROJECT_ID/yarn:node-18.12.0'
  args: ['--version']
- name: 'gcr.io/$PROJECT_ID/yarn:node-19.0.0'
  args: ['--version']
- name: 'gcr.io/$PROJECT_ID/yarn:node-20.11.0'
  args: ['--version']

# Test the examples with :latest

# hello_world
- name: 'gcr.io/$PROJECT_ID/yarn:latest'
  args: ['install']
  dir: 'examples/hello_world'
- name: 'gcr.io/$PROJECT_ID/yarn:latest'
  args: ['test']
  dir: 'examples/hello_world'
- name: 'gcr.io/cloud-builders/docker'
  args: ['build', '.']
  dir: 'examples/hello_world'

images:
- 'gcr.io/$PROJECT_ID/yarn:latest'
- 'gcr.io/$PROJECT_ID/yarn:current'
- 'gcr.io/$PROJECT_ID/yarn:lts'
- 'gcr.io/$PROJECT_ID/yarn:node-8.12.0'
- 'gcr.io/$PROJECT_ID/yarn:node-8.4.0'
- 'gcr.io/$PROJECT_ID/yarn:node-9.11.2'
- 'gcr.io/$PROJECT_ID/yarn:node-10.10.0'
- 'gcr.io/$PROJECT_ID/yarn:node-12.18.3'
- 'gcr.io/$PROJECT_ID/yarn:node-14.10.0'
- 'gcr.io/$PROJECT_ID/yarn:node-14.17.1'
- 'gcr.io/$PROJECT_ID/yarn:node-18.12.0'
- 'gcr.io/$PROJECT_ID/yarn:node-19.0.0'
- 'gcr.io/$PROJECT_ID/yarn:node-20.11.0'

timeout: 2400s
