---
kind: pipeline
type: docker

steps:
  - name: code-analysis
    image: aosapps/drone-sonar-plugin
    settings:
      sonar_host: http://sonarqube:9000
      sonar_token:
        from_secret: sonar_token

  - name: build-amd64
    image: golang:alpine
    commands:
      - apk --no-cache add git go-bindata
      - go generate -v
      - go get -v -d
      - go build -v -o youp0m-linux-amd64
    environment:
      GOOS: linux
      GOARCH: amd64

  - name: build-arm64
    image: golang:alpine
    commands:
      - go build -v -o youp0m-linux-arm64
    environment:
      GOOS: linux
      GOARCH: arm64

  - name: gitea_release
    image: plugins/gitea-release
    settings:
      api_key:
        from_secret: gitea_token
      base_url: http://gitea:3000
      files: youp0m-*
      title: ${DRONE_TAG}
    when:
      event: tag

  - name: publish docker image
    image: plugins/docker
    settings:
      repo: registry:5000/youp0m
      registry: registry:5000
      insecure: true
      auto_tag: true
      auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
