kind: pipeline
type: exec
name: default

steps:
- name: test
  commands:
  - VERSION=${DRONE_TAG:-latest} make test 
  environment:
    DEV_REGISTRY:
      from_secret: dev_registry
  when:
    event:
    - push
    - tag
    - pull_request

- name: build
  commands:
  - VERSION=${DRONE_TAG:-latest} make build
  environment:
    DEV_REGISTRY:
      from_secret: dev_registry
  when:
    event:
    - tag

- name: release
  commands:
  - docker run --rm
      -e DRONE_BUILD_EVENT=tag
      -e DRONE_REPO_OWNER="$DRONE_REPO_OWNER"
      -e DRONE_REPO_NAME="$DRONE_REPO_NAME"
      -e PLUGIN_API_KEY="$API_KEY"
      -e DRONE_COMMIT_REF="refs/tags/$DRONE_TAG"
      -e PLUGIN_OVERWRITE="true"
      -e PLUGIN_FILES="_dist/*"
      -v $(pwd):$(pwd)
      -w $(pwd)
      plugins/github-release
  environment:
    API_KEY:
      from_secret: github_token
  when:
    event: tag