kind: pipeline
name: default

workspace:
  base: /go
  path: src/git.kolaente.de/konrad/Konfi-Castle-Kasino

steps:
  # Needed to get the versions right as they depend on tags
  - name: fetch-tags
    image: docker:git
    commands:
      - git fetch --tags

  - name: build
    image: vikunja/golang-build:latest
    pull: true
    commands:
      - make lint
      - make build
    when:
      event: [ push, tag, pull_request ]
    depends_on: [ fetch-tags ]

  - name: static
    image: techknowlogick/xgo:latest
    pull: true
    environment:
      # This path does not exist. However, when we set the gopath to /go, the build fails. Not sure why.
      # Leaving this here until we know how to resolve this properly.
      GOPATH: /srv/app
    commands:
      - export PATH=$PATH:$GOPATH/bin
      - make release
    depends_on: [ fetch-tags ]

  # Push the releases to our pseudo-s3-bucket
  - name: release
    image: plugins/s3:1
    pull: true
    settings:
      bucket: konfi-castle-casino
      access_key:
        from_secret: aws_access_key_id
      secret_key:
        from_secret: aws_secret_access_key
      endpoint: https://storage.kolaente.de
      path_style: true
      strip_prefix: dist/release/
      source: dist/release/*
      target: /master/
    depends_on: [ static ]