kind: pipeline
type: docker
name: default

steps:
- name: test
  image: docker.io/drycc/go-dev
  pull: always
  privileged: true
  commands:
  - VERSION=${DRONE_TAG:-latest} make test 
  environment:
    DEV_REGISTRY:
      from_secret: dev_registry
  when:
    event:
    - push
    - tag
    - pull_request
  volumes:
  - name: image_registries
    path: /etc/containers/registries.conf

- name: build
  image: docker.io/drycc/go-dev
  pull: always
  privileged: true
  commands:
  - VERSION=${DRONE_TAG:-latest} make build
  environment:
    DEV_REGISTRY:
      from_secret: dev_registry
  when:
    event:
    - tag
  volumes:
  - name: image_registries
    path: /etc/containers/registries.conf

- name: release
  image: plugins/github-release
  settings:
    api_key:
      from_secret: github_token
    files: _dist/*
  when:
    event: tag

trigger:
  event:
  - push
  - tag
  - pull_request

volumes:
- name: image_registries
  host:
    path: /etc/containers/registries.conf
