when:
  event: tag
  ref: refs/tags/v*

variables:
  - &go_image 'golang:1.22'
  - &goreleaser_image 'goreleaser/goreleaser:v1.25.0-nightly'
  - &docker_buildx_image 'woodpeckerci/plugin-docker-buildx'

steps:
  generate:
    image: *go_image
    pull: true
    commands:
      - make generate

  release:
    image: *goreleaser_image
    depends_on:
      - generate
    commands:
      - goreleaser release --clean
    secrets:
      - gitea_token

  docker:
    image: *docker_buildx_image
    depends_on:
      - release
    settings:
      platforms: linux/amd64,linux/arm64
      repo: gitea.dwysokinski.me/twhelp/corev3
      registry: gitea.dwysokinski.me
      dockerfile: ./build/docker/twhelp/prod/Dockerfile
      auto_tag: true
      build_args:
        - CI_COMMIT_TAG=${CI_COMMIT_TAG}
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
