name: Publish Linux

on:
  workflow_call:
    inputs:
      build-flavor:
        required: true
        type: string

    secrets:
      SNAPCRAFT_STORE_CREDENTIALS:
        required: true

jobs:
  snapcraft:
    name: Snapcraft
    runs-on: ubuntu-latest
    steps:
      - name: Setup Environment
        uses: JagandeepBrar/LunaSea/.github/actions/prepare_for_deployment@master
        with:
          channel: snapcraft

      - name: Download Snap
        uses: actions/download-artifact@v3
        with:
          name: linux-snapcraft
          path: ${{ github.workspace }}/output

      - name: Deploy to Snapcraft
        uses: snapcore/action-publish@master
        env:
          SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
        with:
          release: ${{ inputs.build-flavor }}
          snap: ${{ github.workspace }}/output/lunasea-linux-amd64.snap
