name: Releases

on:
  push:
    branches:
      - dev
    tags:
      - '*'

jobs:
  releases:
    runs-on: ubuntu-latest
    timeout-minutes: 60
    steps:
    - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9  # @v3
    - uses: cachix/install-nix-action@6ed004b9ccb68dbc28e7c85bee15fa93dbd214ac  # @v22
      with:
        nix_path: nixpkgs=channel:nixos-unstable

    - name: build pwndbg
      run: nix build '.?submodules=1#pwndbg' -o result-pwndbg

    - name: build rpm
      run: nix build '.?submodules=1#rpm' -o dist-rpm
    - name: build deb
      run: nix build '.?submodules=1#deb' -o dist-deb
    - name: build apk
      run: nix build '.?submodules=1#apk' -o dist-apk
    - name: build archlinux
      run: nix build '.?submodules=1#archlinux' -o dist-archlinux
    - name: build tarball
      run: nix build '.?submodules=1#tarball' -o dist-tarball

    - name: release
      uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # @v1
      with:
        files: |
          ./dist-rpm/*
          ./dist-deb/*
          ./dist-apk/*
          ./dist-archlinux/*
          ./dist-tarball/*
        draft: true
        token: ${{ secrets.TOKEN }}
