labels:
  type: exec
  platform: linux/amd64

steps:
- name: check
  image: bash
  commands:
  - make check
  when:
  - event: tag
    ref: refs/tags/v*
  - event: push
  - event: pull_request

- name: publish
  image: bash
  commands:
  - export BOT_GITHUB_TOKEN=$GITHUB_TOKEN
  - export PULL_BASE_REF=$([ -z $CI_COMMIT_TAG ] && echo latest || echo $CI_COMMIT_TAG)
  - export GIT_REPO=${CI_REPO}
  - export GIT_TAG=${PULL_BASE_REF}
  - make prepare-assets
  - make $([ -z $CI_COMMIT_TAG ] && echo latest-release || echo push-release)
  environment:
    REPO_NAME: ${CI_REPO_NAME}
    REPO_OWNER: ${CI_REPO_OWNER}
  secrets:
  - github_token
  when:
  - event: tag
    ref: refs/tags/v*
  - event: push
