# SPDX-FileCopyrightText: 2018, 2020 Bruce Cowan <bruce@bcowan.me.uk>
# SPDX-License-Identifier: CC0-1.0
flatpak:
  image: fedora:latest
  stage: build
  variables:
    MANIFEST_PATH: "build-aux/uk.me.bcowan.Rugby.json"
    RUNTIME_REPO: "https://flathub.org/repo/flathub.flatpakrepo"
    FLATPAK_MODULE: "rugby"
    BUNDLE: "rugby.flatpak"
    MESON_ARGS: ""
    DBUS_ID: "uk.me.bcowan.Rugby"

  script:
  - dnf install -y flatpak-builder
  - flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
  - flatpak install -y flathub org.gnome.Platform 3.34
  - flatpak install -y flathub org.gnome.Sdk 3.34
  - flatpak-builder --stop-at=${FLATPAK_MODULE} app ${MANIFEST_PATH}
  - flatpak build app meson --prefix=/app ${MESON_ARGS} _build
  - flatpak build app ninja -C _build install
  - flatpak-builder --finish-only --repo=repo app ${MANIFEST_PATH}
  - flatpak build-bundle repo ${BUNDLE} --runtime-repo=${RUNTIME_REPO} ${DBUS_ID}
  artifacts:
    paths:
    - ${BUNDLE}
    - _build/meson-logs/meson-log.txt
  cache:
    paths:
      - .flatpak-builder/cache
