name: Scheduled Release

on:
  workflow_dispatch:
  push:
    tags:
      - v*

permissions:
  contents: write

jobs:
  goreleaser:
    name: Release motr, sonrd, and DWN
    permissions: write-all
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          repository: onsonr/sonr
          fetch-depth: 0
          fetch-tags: true

      - uses: actions/setup-go@v5
        with:
          go-version: "1.22"
          check-latest: true

      - name: Login to Docker Hub
        uses: docker/login-action@v3
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}

      - name: Release
        uses: goreleaser/goreleaser-action@v6
        with:
          distribution: goreleaser-pro
          version: latest
          args: release --clean
        env:
          GITHUB_TOKEN: ${{ secrets.GH_RELEASER_TOKEN }}
          GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
          GITHUB_PERSONAL_AUTH_TOKEN: ${{ secrets.GH_RELEASER_TOKEN }}
          DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
          DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
          TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
