---
kind: pipeline
name: default

platform:
  os: linux
  arch: amd64

steps:
- name: ci
  pull: default
  image: rancher/dapper:1.11.2
  commands:
  - dapper ci
  privileged: true
  volumes:
  - name: socket
    path: /var/run/docker.sock

- name: build-all-binaries
  pull: default
  image: rancher/dapper:1.11.2
  commands:
  - dapper build
  - ls -lR dist/artifacts
  environment:
    CROSS: 1
  privileged: true
  volumes:
  - name: socket
    path: /var/run/docker.sock
  when:
    event:
    - tag
    ref:
      include:
      - "refs/tags/*"

- name: stage-binaries
  pull: default
  image: rancher/dapper:1.11.2
  commands:
  - "cp -r ./bin/* ./package/"
  when:
    event:
    - tag
    ref:
      include:
      - "refs/tags/*"

- name: github_binary_prerelease
  pull: default
  image: plugins/github-release
  settings:
    api_key:
      from_secret: github_token
    checksum:
    - sha256
    files:
    - "build/bin/rke_*"
    - "dist/artifacts/${DRONE_TAG}/*"
    prerelease: true
  when:
    event:
    - tag
    ref:
      include:
      - "refs/tags/*rc*"
      - "refs/tags/*alpha*"

- name: github_binary_release
  pull: default
  image: plugins/github-release
  settings:
    checksum:
    - sha256
    files:
    - "build/bin/rke_*"
    - "dist/artifacts/${DRONE_TAG}/*"
    api_key:
      from_secret: github_token
  when:
    event:
    - tag
    ref:
      exclude:
      - "refs/tags/*rc*"
      - "refs/tags/*alpha*"

volumes:
- name: socket
  host:
    path: /var/run/docker.sock
