name: release

on:
  push:
    tags:
    - 'v*'

jobs:
  release:
    runs-on: ubuntu-22.04

    steps:
      - id: get-version
        uses: battila7/get-version-action@v2

      - uses: actions/checkout@v2
        with:
          submodules: true
      
      - id: release-asset
        run: |
          version=${{ steps.get-version.outputs.version-without-v }}
          cd ..
          cp -r rtty rtty-$version
          rm -rf rtty-$version/.git* rtty-$version/src/buffer/.git* rtty-$version/src/ssl/.git* rtty-$version/src/log/.git*
          tar zcfv rtty-$version.tar.gz rtty-$version

      - uses: marvinpinto/action-automatic-releases@latest
        with:
          repo_token: ${{ secrets.GITHUB_TOKEN }}
          draft: true
          prerelease: false
          files: ../rtty-*.tar.gz
