name: "Continuous build (FreeBSD)"

on:
  push:
    branches:
      - '*'
    tags-ignore:
      - 'continuous*'

jobs:
  build:
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            arch: x86_64
            dependencies: argp-standalone automake bash cmake desktop-file-utils gcc git gmake gpgme libtool meson nasm perl5 pkgconf python squashfs-tools sudo wget wine yasm zip zsync

          - os: ubuntu-latest
            arch: aarch64
            dependencies: argp-standalone automake bash cmake desktop-file-utils gcc git gmake gpgme libtool meson nasm perl5 pkgconf python squashfs-tools sudo wget yasm zip zsync

      fail-fast: false

    runs-on: ${{ matrix.os }}

    env:
      AppImageArch: ${{ matrix.arch }}
      RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}

    steps:
      - name: Checkout repository
        uses: actions/checkout@v6
        with:
          submodules: recursive

      - name: Free up space
        run: |
          rm -fr boca/system-*

      - name: Start VM
        id: vm
        uses: vmactions/freebsd-vm@v1
        with:
          release: "13.5"
          arch: ${{ matrix.arch }}
          envs: 'AppImageArch RELEASE_TOKEN'
          sync: sshfs

      - name: Install dependencies
        shell: freebsd {0}
        run: |
          pkg update
          pkg install -y ${{ matrix.dependencies }}
          pkg install -y gnome-icon-theme gtk3

      - name: Build AppImage
        shell: freebsd {0}
        run: |
          pw user add -n vmuser -m -g wheel
          echo "vmuser ALL=(ALL) NOPASSWD: ALL" >> /usr/local/etc/sudoers
          cp -R $GITHUB_WORKSPACE .
          chown -R vmuser freac
          cd freac
          su vmuser -c .github/workflows/tools/build-appimage
