CI/CD with Flatpak

Neelaksh SinghNeelaksh Singh
3 min read

My Season of KDE Journey

My first interaction with the KDE community came in 2022 when I got a chance to interact with the KDE console and loved the UI interface for the Neon distro. This was enough to get me started with the KDE ecosystem.

This January I got a chance to work as a student developer under Season of KDE, for the Flatpak project. My task was to achieve the Automated and systematizing internal processes goal of KDE, I aided in the migration of Flatpak builds for almost 50+ KDE applications on Flathub to leverage the KDE Platform SDK infrastructure on GitLab. This would help in automating Flatpak packaging in GitLab Invent CI.

There already exists manifests for KDE applications hosted on Flathub. My work aimed to move manifest files for as many of these KDE applications to their respective repository on GitLab, to give benefits from checks during Merge Requests via KDE Invent's GitLab CI.

Furthermore, I added these applications to the Nightly repository, by adding their respective .remoteapp file to Flatpak.

In addition to adding manifests, I also added CC0-1.0 SPDX Licence to these repositories in form of a .flatpak-manifest.json.license file, to meet the reuse test.

How it Works

To showcase this through an example, I would be taking the merge request I created for Gwenview.

A. Adding Flatpak Manifest to Repository

The user adds the application manifest to their respective repository.

  1. To add the Flatpak manifest to the source repository create .flatpak-manifest.json or .flatpak-manifest.yml, in the main directory.

  2. In the manifest change source of the application to use the current directory.

     {
       "name": "gwenview",
       "buildsystem": "cmake-ninja",
       "builddir": true,
       "sources": [
         {
           "type": "dir",
           "path": "."
         }
       ]
     }
    

B. Add Flatpak CI to your application

We enable Flatpak CI to build for our application on every pipeline run. These builds also generate artifacts.

To do this add the following in .gitlab-ci.yml .

include:
    ...
    - https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/flatpak.yml

C. Adding Licence File

# SPDX-FileCopyrightText: None
# SPDX-License-Identifier: CC0-1.0

Once the above steps are completed, on successfully running the pipeline we get the build artifacts. You can see from here that the job ran successfully and created the corresponding artifacts.

One can download the artifact, unzip them and run the application.

Nightly Builds

Once the pipelines were up and running, the next step was to migrate these applications from the Flatpak repository to a Nightly build.

To do these, we create a .remoteapp file for these applications in the flatpak repository and remove their corresponding manifest from there.

ID=org.kde.gwenview
JSON=.flatpak-manifest.json
GITURL=https://invent.kde.org/graphics/gwenview.git

To create one for yourself, just replace the ID and GITURL with the corresponding application values.

Final Thoughts

Throughout this program, I got to learn about the Flatpak Packaging methodology, build terms associated with different applications and got a great mentorship.

The final commit which summarises my fellowship can be viewed here.

0
Subscribe to my newsletter

Read articles from Neelaksh Singh directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Neelaksh Singh
Neelaksh Singh