name: Draft Release

on:
  push:
    tags:
      - 'v*'

permissions:
  contents: write

jobs:
  build_release:
    name: build_release
    runs-on: ubuntu-latest

    steps:
      - name: checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: version
        run: echo "tag_ver=$(./tools/get_version.sh)" >> $GITHUB_ENV

      - name: Run Build Appimage QT5
        run: make appimage-qt5

      - name: Run Build test deb
        run: make deb

      - name: Get latest changelog entries
        run: ./tools/changelog_latest.sh > CHANGELOG.latest

      - name: release-draft
        uses: softprops/action-gh-release@v2
        with:
          draft: true
          prerelease: false
          name: CQRLOG v${{ env.tag_ver }}
          tag_name: ${{ github.ref_name }}
          body_path: CHANGELOG.latest
          files: |
            cqrlog_*.deb
            CQRLOG-*-QT5-*.AppImage
        env:
          GITHUB_TOKEN: ${{ github.token }}
