name: Releases manual

on: workflow_dispatch

jobs:
  releases-linux-cross:
    strategy:
      fail-fast: false
      matrix:
        attribute: [
          # gdb
          pwndbg-gdb-cross-arm32-tarball,
          pwndbg-gdb-cross-riscv64-tarball,
          pwndbg-gdb-cross-s390x-tarball,
          pwndbg-gdb-cross-ppc64-tarball,
          pwndbg-gdb-cross-ppc64le-tarball,
          pwndbg-gdb-cross-x86_32-tarball,

          # lldb
          pwndbg-lldb-cross-arm32-tarball,
          pwndbg-lldb-cross-riscv64-tarball,
          pwndbg-lldb-cross-s390x-tarball,
#          pwndbg-lldb-cross-ppc64-tarball,  # broken lldb compilation
          pwndbg-lldb-cross-ppc64le-tarball,
          pwndbg-lldb-cross-x86_32-tarball,
        ]
    runs-on: ubuntu-latest  # x86_64-linux
    timeout-minutes: 360
    steps:
    - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9  # @v3
    - uses: cachix/install-nix-action@08dcb3a5e62fa31e2da3d490afc4176ef55ecd72  # @v30
      with:
        nix_path: nixpkgs=channel:nixos-unstable

    - name: build ${{ matrix.attribute }}
      run: nix build '.#${{ matrix.attribute }}' --accept-flake-config -o dist-tarball

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

  releases-linux:
    strategy:
      fail-fast: false
      matrix:
        os: [
          ubuntu-latest,  # x86_64-linux
          ubuntu-24.04-arm,  # aarch64-linux
        ]
        attribute: [
          pwndbg-lldb-portable-tarball,
          pwndbg-gdb-portable-tarball,
          pwndbg-gdb-portable-rpm,
          pwndbg-gdb-portable-deb,
          pwndbg-gdb-portable-apk,
          pwndbg-gdb-portable-archlinux,
        ]
    runs-on: ${{ matrix.os }}
    timeout-minutes: 60
    steps:
    - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9  # @v3
    - uses: cachix/install-nix-action@08dcb3a5e62fa31e2da3d490afc4176ef55ecd72  # @v30
      with:
        nix_path: nixpkgs=channel:nixos-unstable

    - name: build ${{ matrix.attribute }}
      run: nix build '.#${{ matrix.attribute }}' --accept-flake-config -o dist-tarball

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

  releases-macos:
    strategy:
      fail-fast: false
      matrix:
        os: [
          macos-13,  # x86_64-darwin
          macos-15,  # aarch64-darwin
        ]
        attribute: [
          pwndbg-lldb-portable-tarball,
        ]
        include:
          # gdb is only supported on macos x86_64
          - os: macos-13  # x86_64-darwin
            attribute: pwndbg-gdb-portable-tarball
    runs-on: ${{ matrix.os }}
    timeout-minutes: 60
    steps:
    - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9  # @v3
    - uses: cachix/install-nix-action@08dcb3a5e62fa31e2da3d490afc4176ef55ecd72  # @v30
      with:
        nix_path: nixpkgs=channel:nixos-unstable

    - name: build ${{ matrix.attribute }}
      run: nix build '.#${{ matrix.attribute }}' --accept-flake-config -o dist-tarball

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