version: v1.0
name: Publish node images
agent:
  machine:
    type: f1-standard-2
    os_image: ubuntu2204

execution_time_limit:
  minutes: 60

global_job_config:
  env_vars:
    - name: DEV_REGISTRIES
      value: quay.io/calico docker.io/calico
  secrets:
    - name: docker
    - name: quay-robot-calico+semaphoreci
  prologue:
    commands:
      - checkout
      # Semaphore is doing shallow clone on a commit without tags.
      # unshallow it for GIT_VERSION:=$(shell git describe --tags --dirty --always)
      - retry git fetch --unshallow
      - echo $DOCKER_TOKEN | docker login --username "$DOCKER_USER" --password-stdin
      - echo $QUAY_TOKEN | docker login --username "$QUAY_USER" --password-stdin quay.io
      - export BRANCH_NAME=$SEMAPHORE_GIT_BRANCH

blocks:
  - name: "Publish node images"
    dependencies: []
    skip:
      when: "branch !~ '.+'"
    task:
      jobs:
        - name: Linux multi-arch
          commands:
            - if [ -z "${SEMAPHORE_GIT_PR_NUMBER}" ]; then make -C node cd EXCLUDEARCH=arm64 CONFIRM=true; fi
        - name: Windows
          commands:
            - if [ -z "${SEMAPHORE_GIT_PR_NUMBER}" ]; then make -C node release-windows CONFIRM=true; fi
  - name: Publish node images - native arm64 runner
    dependencies: []
    skip:
      when: "branch !~ '.+'"
    task:
      agent:
        machine:
          type: s1-aws-arm64-2
      jobs:
        - name: Linux arm64
          commands:
            # Don't call `make -C node cd ARCHES=arm64` here because node image-all also builds
            # FIPS images that will fail on native arm64 runners. They are built in the previous block.
            - if [ -z "${SEMAPHORE_GIT_PR_NUMBER}" ]; then make -C node image cd-common ARCH=arm64 VALIDARCHES=arm64 CONFIRM=true; fi
  - name: Publish node multi-arch manifests
    dependencies:
      - Publish node images
      - "Publish node images - native arm64 runner"
    skip:
      when: "branch !~ '.+'"
    task:
      jobs:
        - name: Linux multi-arch manifests
          commands:
            - if [ -z "${SEMAPHORE_GIT_PR_NUMBER}" ]; then make -C node push-manifests-with-tag CONFIRM=true; fi
