
name: "Snapshot"


on:
  workflow_dispatch:
    inputs:
      prerelease:
        description: "Create a pre-release"
        default: false
        required: true
        type: boolean
  pull_request:
    branches:
      - main
    types: [closed]


permissions:
  contents: write
  discussions: write


jobs:

  version:
    name: Describe
    uses: ./.github/workflows/job_version.yml

  title:
    needs: version
    name: Version ${{ needs.version.outputs.version }}
    runs-on: ubuntu-latest
    steps:
      - run: "true"

  prerelease:
    if: ${{ inputs.prerelease }}
    needs: version
    name: Create pre-release
    runs-on: ubuntu-latest
    steps:
    - uses: ncipollo/release-action@v1
      with:
        tag: ${{ needs.version.outputs.version }}
        commit: "main"
        name: Pre-release ${{ needs.version.outputs.version }}
        draft: false
        prerelease: true
        generateReleaseNotes: true
        discussionCategory: "Releases"
        makeLatest: false

  ubuntu:
    needs: version
    name: Ubuntu
    uses: ./.github/workflows/job_ubuntu.yml
    with:
      version: ${{ needs.version.outputs.version }}
  ubuntu-release:
    if: ${{ inputs.prerelease }}
    needs: [version, prerelease, ubuntu]
    name: Ubuntu
    uses: ./.github/workflows/job_release.yml
    with:
      version: ${{ needs.version.outputs.version }}
      file1: Rare.deb
      name1: Rare-${{ needs.version.outputs.version }}.deb

  appimage:
    needs: version
    name: AppImage
    uses: ./.github/workflows/job_appimage.yml
    with:
      version: ${{ needs.version.outputs.version }}
  appimage-release:
    if: ${{ inputs.prerelease }}
    needs: [version, prerelease, appimage]
    name: AppImage
    uses: ./.github/workflows/job_release.yml
    with:
      version: ${{ needs.version.outputs.version }}
      file1: Rare.AppImage
      name1: Rare-${{ needs.version.outputs.version }}.AppImage
      file2: Rare.AppImage.zsync
      name2: Rare-${{ needs.version.outputs.version }}.AppImage.zsync

  nuitka-win:
    if: ${{ false }}
    needs: version
    name: Nuitka Windows
    uses: ./.github/workflows/job_nuitka-win.yml
    with:
      version: ${{ needs.version.outputs.version }}
  nuitka-win-release:
    if: ${{ inputs.prerelease }}
    needs: [version, prerelease, nuitka-win]
    name: Nuitka Windows
    uses: ./.github/workflows/job_release.yml
    with:
      version: ${{ needs.version.outputs.version }}
      file1: Rare-Windows.zip
      name1: Rare-Windows-${{ needs.version.outputs.version }}.zip

  cx-freeze-msi:
    needs: version
    name: cx-Freeze msi
    uses: ./.github/workflows/job_cx-freeze-msi.yml
    with:
      version: ${{ needs.version.outputs.version }}
  cx-freeze-msi-release:
    if: ${{ inputs.prerelease }}
    needs: [version, prerelease, cx-freeze-msi]
    name: cx-Freeze msi
    uses: ./.github/workflows/job_release.yml
    with:
      version: ${{ needs.version.outputs.version }}
      file1: Rare.msi
      name1: Rare-${{ needs.version.outputs.version }}.msi

  cx-freeze-zip:
    needs: version
    name: cx-Freeze zip
    uses: ./.github/workflows/job_cx-freeze-zip.yml
    with:
      version: ${{ needs.version.outputs.version }}
  cx-freeze-zip-release:
    if: ${{ inputs.prerelease }}
    needs: [version, prerelease, cx-freeze-zip]
    name: cx-Freeze zip
    uses: ./.github/workflows/job_release.yml
    with:
      version: ${{ needs.version.outputs.version }}
      file1: Rare-Windows.zip
      name1: Rare-Windows-${{ needs.version.outputs.version }}.zip

  macos:
    needs: version
    name: macOS
    uses: ./.github/workflows/job_macos.yml
    with:
      version: ${{ needs.version.outputs.version }}
  macos-release:
    if: ${{ inputs.prerelease }}
    needs: [version, prerelease, macos]
    name: macOS
    uses: ./.github/workflows/job_release.yml
    with:
      version: ${{ needs.version.outputs.version }}
      file1: Rare.dmg
      name1: Rare-${{ needs.version.outputs.version }}.dmg

