name: All Source Files

on:
  push:
  release:
    types: [published, edited]

jobs:
  linux:
    name: All Source Files
    runs-on: ubuntu-latest

    steps:
      - name: Install git
        run: |
          sudo apt-get update
          sudo apt-get install -y git
      - name: Get the version
        id: get_version
        shell: bash
        run: echo "VERSION=$(echo $GITHUB_REF | cut -d / -f 3)" >> $GITHUB_OUTPUT
      - name: Checking out sources
        uses: actions/checkout@v6
        with:
          submodules: "recursive"
      - name: Create 7z Release
        uses: DuckSoft/create-7z-action@v1.0
        with:
          pathSource: ./
          pathTarget: ./Lemon-${{ steps.get_version.outputs.VERSION }}-source-all.7z
      - name: Upload artifact
        uses: actions/upload-artifact@v7
        with:
          name: Lemon-${{ steps.get_version.outputs.VERSION }}-source-all.7z
          path: Lemon-${{ steps.get_version.outputs.VERSION }}-source-all.7z
      - name: Upload binaries to release
        uses: svenstaro/upload-release-action@v2
        if: startsWith(github.event.ref, 'refs/tags/')
        with:
          repo_token: ${{ secrets.GITHUB_TOKEN }}
          file: Lemon-${{ steps.get_version.outputs.VERSION }}-source-all.7z
          asset_name: Lemon-${{ steps.get_version.outputs.VERSION }}-source-all.7z
          tag: ${{ github.ref }}
          overwrite: true
