
name: "Snapshot"


on:
  workflow_dispatch:
  pull_request:
    branches:
      - main
    types: [closed]


jobs:

  version:
    name: Describe
    runs-on: ubuntu-latest
    outputs:
      tag_abbrev: ${{ steps.describe.outputs.tag_abbrev }}
      tag_offset: ${{ steps.describe.outputs.tag_offset }}
      sha_short: ${{ steps.describe.outputs.sha_short }}
      full_desc: ${{ steps.describe.outputs.full_desc }}
      branch: ${{ steps.describe.outputs.branch }}
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: Describe version
        id: describe
        shell: bash
        run: |
          tag_abbrev=$(git tag --sort=v:refname | grep -oE "(^[0-9]+\.[0-9]+(.[0-9]+)?)$" | tail -1)
          echo "tag_abbrev=$tag_abbrev" >> $GITHUB_OUTPUT
          echo "tag_offset=$(git rev-list $tag_abbrev..HEAD --count)" >> $GITHUB_OUTPUT
          echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
          echo "full_desc=$(git describe --long --tags)" >> $GITHUB_OUTPUT
          echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT

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

  ubuntu:
    needs: version
    name: Ubuntu
    uses: ./.github/workflows/job_ubuntu.yml
    with:
      version: ${{ needs.version.outputs.tag_abbrev }}.${{ needs.version.outputs.tag_offset }}

  appimage:
    needs: version
    name: AppImage
    uses: ./.github/workflows/job_appimage.yml
    with:
      version: ${{ needs.version.outputs.tag_abbrev }}.${{ needs.version.outputs.tag_offset }}

  nuitka-win:
    if: ${{ false }}
    needs: version
    name: Nuitka Windows
    uses: ./.github/workflows/job_nuitka-win.yml
    with:
      version: ${{ needs.version.outputs.tag_abbrev }}.${{ needs.version.outputs.tag_offset }}

  cx-freeze-msi:
    needs: version
    name: cx-Freeze msi
    uses: ./.github/workflows/job_cx-freeze-msi.yml
    with:
      version: ${{ needs.version.outputs.tag_abbrev }}.${{ needs.version.outputs.tag_offset }}

  cx-freeze-zip:
    needs: version
    name: cx-Freeze zip
    uses: ./.github/workflows/job_cx-freeze-zip.yml
    with:
      version: ${{ needs.version.outputs.tag_abbrev }}.${{ needs.version.outputs.tag_offset }}

  macos:
    needs: version
    name: MacOS
    uses: ./.github/workflows/job_macos.yml
    with:
      version: ${{ needs.version.outputs.tag_abbrev }}.${{ needs.version.outputs.tag_offset }}

