name: Release

on:
  release:
    types: [published]

permissions:
  contents: write

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - name: deps
      run: sudo apt-get install libgcrypt20-dev xa65 doxygen graphviz
    - uses: actions/checkout@v7
      with:
        submodules: 'true'
        ref: ${{ github.ref }}
    - name: Bootstrap
      run: autoreconf -vfi
    - name: Configure
      run: ./configure
    - name: Prepare package
      id: package-generator
      run: |
        make dist
        RELEASE_TARBALL=$(ls libsidplayfp-*.tar.gz)
        echo "filename=${RELEASE_TARBALL}" >> $GITHUB_OUTPUT
    - name: Upload to release
      uses: JasonEtco/upload-to-release@master
      with:
        args: ${{ steps.package-generator.outputs.filename }} application/gzip
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
