name: Release

on:
  workflow_dispatch:
  workflow_call:

jobs:
  release:
    name: Upload the release
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Generate a changelog
        uses: orhun/git-cliff-action@v4
        id: git-cliff
        with:
          config: cliff.toml
          args: -vv --latest --strip header
        env:
          OUTPUT: CHANGES.md
          GITHUB_REPO: ${{ github.repository }}

      - name: Release
        uses: softprops/action-gh-release@v2
        with:
          body_path: CHANGES.md
          repository: ${{ github.repository }}
          token: ${{ secrets.GITHUB_TOKEN }}
