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

  script:
  - apk update && apk add flatpak-builder
  - flatpak remote-add --if-not-exists gnome-nightly https://nightly.gnome.org/gnome-nightly.flatpakrepo
  - flatpak install -y flathub org.gnome.Platform master
  - flatpak install -y flathub org.gnome.Sdk master
  - 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} ${APP_ID}
  artifacts:
    paths:
    - ${BUNDLE}
    - _build/meson-logs/meson-log.txt
  cache:
    paths:
      - .flatpak-builder/cache
