---
kind: pipeline
name: windows-amd64

platform:
  os: windows
  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/windows/amd64/drone-telegram'
    environment:
      CGO_ENABLED: 0
      GO111MODULE: on
    when:
      event:
        - push
        - pull_request

  - 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/windows/amd64/drone-telegram'
    environment:
      CGO_ENABLED: 0
      GO111MODULE: on
    when:
      event:
        - tag

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

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

  - name: publish
    pull: always
    image: plugins/docker:windows-amd64
    settings:
      auto_tag: true
      auto_tag_suffix: windows-amd64
      dockerfile: docker/Dockerfile.windows.amd64
      password:
        from_secret: docker_password
      repo: appleboy/drone-telegram
      username:
        from_secret: docker_username
    when:
      event:
        - push
        - tag

trigger:
  branch:
    - master
