---
kind: pipeline
name: testing

platform:
  os: linux
  arch: amd64

steps:
- name: vet
  pull: always
  image: golang:1.11
  commands:
  - make vet
  environment:
    GO111MODULE: on
  volumes:
  - name: gopath
    path: /go

- name: lint
  pull: always
  image: golang:1.11
  commands:
  - make lint
  environment:
    GO111MODULE: on
  volumes:
  - name: gopath
    path: /go

- name: misspell
  pull: always
  image: golang:1.11
  commands:
  - make misspell-check
  environment:
    GO111MODULE: on
  volumes:
  - name: gopath
    path: /go

- name: test
  pull: always
  image: golang:1.11
  commands:
  - make test
  - make coverage
  environment:
    GO111MODULE: on
    TELEGRAM_TO:
      from_secret: telegram_to
    TELEGRAM_TOKEN:
      from_secret: telegram_token
  volumes:
  - name: gopath
    path: /go

- name: codecov
  pull: always
  image: robertstettner/drone-codecov
  settings:
    token:
      from_secret: codecov_token

volumes:
- name: gopath
  temp: {}

---
kind: pipeline
name: linux-amd64

platform:
  os: linux
  arch: amd64

steps:
- name: build-push
  pull: always
  image: golang:1.11
  commands:
  - "go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/amd64/drone-telegram"
  environment:
    CGO_ENABLED: 0
    GO111MODULE: on
  when:
    event:
      exclude:
      - tag

- name: build-tag
  pull: always
  image: golang:1.11
  commands:
  - "go build -v -ldflags '-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/amd64/drone-telegram"
  environment:
    CGO_ENABLED: 0
    GO111MODULE: on
  when:
    event:
    - tag

- name: executable
  pull: always
  image: golang:1.11
  commands:
  - ./release/linux/amd64/drone-telegram --help

- name: dryrun
  pull: always
  image: plugins/docker:linux-amd64
  settings:
    cache_from: appleboy/drone-telegram
    dockerfile: docker/Dockerfile.linux.amd64
    dry_run: true
    password:
      from_secret: docker_password
    repo: appleboy/drone-telegram
    tags: linux-amd64
    username:
      from_secret: docker_username
  when:
    event:
    - pull_request

- name: publish
  pull: always
  image: plugins/docker:linux-amd64
  settings:
    auto_tag: true
    auto_tag_suffix: linux-amd64
    cache_from: appleboy/drone-telegram
    daemon_off: false
    dockerfile: docker/Dockerfile.linux.amd64
    password:
      from_secret: docker_password
    repo: appleboy/drone-telegram
    username:
      from_secret: docker_username
  when:
    event:
      exclude:
      - pull_request

trigger:
  ref:
  - refs/heads/master
  - "refs/pull/**"
  - "refs/tags/**"

depends_on:
- testing

---
kind: pipeline
name: linux-arm64

platform:
  os: linux
  arch: arm64

steps:
- name: build-push
  pull: always
  image: golang:1.11
  commands:
  - "go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm64/drone-telegram"
  environment:
    CGO_ENABLED: 0
    GO111MODULE: on
  when:
    event:
      exclude:
      - tag

- name: build-tag
  pull: always
  image: golang:1.11
  commands:
  - "go build -v -ldflags '-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm64/drone-telegram"
  environment:
    CGO_ENABLED: 0
    GO111MODULE: on
  when:
    event:
    - tag

- name: executable
  pull: always
  image: golang:1.11
  commands:
  - ./release/linux/arm64/drone-telegram --help

- name: dryrun
  pull: always
  image: plugins/docker:linux-arm64
  settings:
    cache_from: appleboy/drone-telegram
    dockerfile: docker/Dockerfile.linux.arm64
    dry_run: true
    password:
      from_secret: docker_password
    repo: appleboy/drone-telegram
    tags: linux-arm64
    username:
      from_secret: docker_username
  when:
    event:
    - pull_request

- name: publish
  pull: always
  image: plugins/docker:linux-arm64
  settings:
    auto_tag: true
    auto_tag_suffix: linux-arm64
    cache_from: appleboy/drone-telegram
    daemon_off: false
    dockerfile: docker/Dockerfile.linux.arm64
    password:
      from_secret: docker_password
    repo: appleboy/drone-telegram
    username:
      from_secret: docker_username
  when:
    event:
      exclude:
      - pull_request

trigger:
  ref:
  - refs/heads/master
  - "refs/pull/**"
  - "refs/tags/**"

depends_on:
- testing

---
kind: pipeline
name: linux-arm

platform:
  os: linux
  arch: arm

steps:
- name: build-push
  pull: always
  image: golang:1.11
  commands:
  - "go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm/drone-telegram"
  environment:
    CGO_ENABLED: 0
    GO111MODULE: on
  when:
    event:
      exclude:
      - tag

- name: build-tag
  pull: always
  image: golang:1.11
  commands:
  - "go build -v -ldflags '-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm/drone-telegram"
  environment:
    CGO_ENABLED: 0
    GO111MODULE: on
  when:
    event:
    - tag

- name: executable
  pull: always
  image: golang:1.11
  commands:
  - ./release/linux/arm/drone-telegram --help

- name: dryrun
  pull: always
  image: plugins/docker:linux-arm
  settings:
    cache_from: appleboy/drone-telegram
    dockerfile: docker/Dockerfile.linux.arm
    dry_run: true
    password:
      from_secret: docker_password
    repo: appleboy/drone-telegram
    tags: linux-arm
    username:
      from_secret: docker_username
  when:
    event:
    - pull_request

- name: publish
  pull: always
  image: plugins/docker:linux-arm
  settings:
    auto_tag: true
    auto_tag_suffix: linux-arm
    cache_from: appleboy/drone-telegram
    daemon_off: false
    dockerfile: docker/Dockerfile.linux.arm
    password:
      from_secret: docker_password
    repo: appleboy/drone-telegram
    username:
      from_secret: docker_username
  when:
    event:
      exclude:
      - pull_request

trigger:
  ref:
  - refs/heads/master
  - "refs/pull/**"
  - "refs/tags/**"

depends_on:
- testing

---
kind: pipeline
name: release-binary

platform:
  os: linux
  arch: amd64

steps:
- name: build-all-binary
  pull: always
  image: golang:1.11
  commands:
  - make release
  environment:
    GO111MODULE: on
  when:
    event:
    - tag

- name: deploy-all-binary
  pull: always
  image: plugins/github-release
  settings:
    api_key:
      from_secret: github_release_api_key
    files:
    - "dist/release/*"
  when:
    event:
    - tag

trigger:
  ref:
  - "refs/tags/**"

depends_on:
- testing

---
kind: pipeline
name: notifications

platform:
  os: linux
  arch: amd64

steps:
- name: manifest
  pull: always
  image: plugins/manifest
  settings:
    ignore_missing: true
    password:
      from_secret: docker_password
    spec: docker/manifest.tmpl
    username:
      from_secret: docker_username

- name: microbadger
  pull: always
  image: plugins/webhook:1
  settings:
    url:
      from_secret: microbadger_url

trigger:
  ref:
  - refs/heads/master
  - "refs/tags/**"

depends_on:
- linux-amd64
- linux-arm64
- linux-arm
- release-binary

---
kind: signature
hmac: 9a4dcc3659b6f2cb98486e40e4cb0c16d6fc19ad783d3bca13d30c476daf8213

...
