name: Version release

on:
  push:
    tags:
      - 'v*.*.*'

jobs:
  run-distcheck:
    uses: ./.github/workflows/dist_check.yaml

  create-dist-archives:
    needs: run-distcheck
    uses: ./.github/workflows/dist_archives.yaml
    with:
      zip: true
      artifact-name: 'dist-archives'

  create-release:
    needs: [run-distcheck, create-dist-archives]
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
    - uses: actions/checkout@v3
    - uses: actions/download-artifact@v3
      with:
        name: dist-archives
    - name: Extract release notes
      id: extract-release-notes
      uses: RaumZeit/extract-release-notes@a991ec1541871118630638fe002862a023870cff
      with:
        header_level: 3
        version_prefix: "Version"
    - name: Make release
      uses: ncipollo/release-action@v1
      with:
        artifacts: "ViennaRNA-*.tar.gz,ViennaRNA-*.zip"
        body: ${{ steps.extract-release-notes.outputs.release_notes }}
