name: Build AppImage

on:
  push:
    branches:
      - 'main'
      - 'staging'

env:
  APPDIR: WlxOverlay-S.AppDir
  CARGO_TERM_COLOR: always
  SCCACHE_GHA_ENABLED: "true"
  RUSTC_WRAPPER: "sccache"
  
jobs:
  build_appimage:
    runs-on: ubuntu-22.04
    defaults:
      run:
        working-directory: ./wlx-overlay-s
    steps:
      - uses: actions/checkout@v3
      - name: Setup sccache
        uses: mozilla-actions/sccache-action@v0.0.9
      - name: Prepare Environment
        run: |
          ../.github/workflows/scripts/appimage_prepare_env.sh
      - name: Cargo Build
        run: |
          ../.github/workflows/scripts/appimage_build_wlx.sh
      - name: Package AppImage
        run: |
          ../.github/workflows/scripts/appimage_package.sh
      - name: Upload AppImage
        uses: actions/upload-artifact@v4
        with:
          name: WlxOverlay-S-${{ github.ref_name }}-x86_64.AppImage
          path: ./wlx-overlay-s/WlxOverlay-S-x86_64.AppImage
