name: build-and-test
on:
  push:
    tags:
      - "*"

jobs:
  release:
    name: Build Release Assets
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Set up Go
        uses: actions/setup-go@v5
        with:
          go-version: 1.22.11

      - name: Build the executables
        run: ./mkrel.sh anydb ${{ github.ref_name}}

      - name: List the executables
        run: ls -l ./releases

      - name: Upload the binaries
        uses: svenstaro/upload-release-action@v2
        with:
          repo_token: ${{ secrets.GITHUB_TOKEN }}
          tag: ${{ github.ref_name }}
          file: ./releases/*
          file_glob: true

      - name: Build Changelog
        id: github_release
        uses: mikepenz/release-changelog-builder-action@v5
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          mode: "PR"

      - name: Create Release
        uses: mikepenz/action-gh-release@v0.2.0-a03
        with:
          body: ${{steps.github_release.outputs.changelog}}
