version: v1.0
name: Publish openstack packages
agent:
  machine:
    type: e1-standard-4
    os_image: ubuntu2004

execution_time_limit:
  minutes: 60

global_job_config:
  secrets:
    - name: google-service-account-for-tigera-infra
    - name: launchpad-secret-key
  prologue:
    commands:
      - checkout
      # Semaphore is doing shallow clone on a commit without tags.
      # unshallow it because we need a reliable git describe.
      - retry git fetch --unshallow
      - git config --global user.email marvin@tigera.io
      - git config --global user.name Marvin
      - export GOOGLE_APPLICATION_CREDENTIALS=$HOME/secrets/tigera-infra-access.json
      - gcloud config set project tigera-wp-tcp-redirect
      - gcloud auth activate-service-account --key-file=$GOOGLE_APPLICATION_CREDENTIALS
      - export SECRET_KEY=$HOME/secrets/marvin.txt
      - export GCLOUD_ARGS='--zone us-east1-c --project tigera-wp-tcp-redirect'
      - export HOST=ubuntu@binaries-projectcalico-org
      - sudo apt-get update -y
      - sudo apt-get install -y moreutils patchelf

blocks:
  - name: "Publish openstack packages"
    skip:
      # Only run on branches, not PRs.
      #
      # This promotion is only _automatic_ for the master branch.  For other
      # branches, it is an available promotion, but not automatic.  This makes
      # it easy for a developer to trigger the building and publishing of
      # release branch packages, simply by clicking the "Publish openstack
      # packages" button in the Semaphore UI.  When building from the master
      # branch, packages are published to the "master" PPA.  When building from
      # any other branch, packages are published to the "testing" PPA.
      when: "branch !~ '.+'"
    task:
      jobs:
        - name: "packages"
          commands:
            - if [ -z "${SEMAPHORE_GIT_PR_NUMBER}" ]; then make -C hack/release/packaging release-publish VERSION=$SEMAPHORE_GIT_BRANCH; fi
