Merge branch 'flatpak-ci' into 'main'

Flatpak CI

See merge request veilid/veilidchat!23
This commit is contained in:
Christien Rioux 2024-04-01 21:45:02 +00:00
commit 8da1dc7d32
8 changed files with 246 additions and 3 deletions

7
.gitignore vendored
View File

@ -51,8 +51,13 @@ app.*.map.json
/android/app/debug
/android/app/profile
/android/app/release
/android/key.properties
# WASM
/web/wasm/
android/key.properties
# Flatpak
flatpak/build-dir/
flatpak/repo/
flatpak/.flatpak-builder/
*.flatpak

View File

@ -3,6 +3,7 @@
stages:
- build
- build_flatpak
# - test
.macos_saas_runners:
@ -12,7 +13,7 @@ stages:
before_script:
- echo "started by ${GITLAB_USER_NAME}"
build:
build_macos:
extends:
- .macos_saas_runners
stage: build
@ -36,10 +37,45 @@ build:
#- flutter build appbundle
when: manual
build_linux_amd64_bundle:
tags:
- saas-linux-medium-amd64
image: ghcr.io/cirruslabs/flutter:3.19.4
stage: build
script:
- apt-get update
- apt-get install -y --no-install-recommends cmake ninja-build clang build-essential pkg-config libgtk-3-dev liblzma-dev lcov rustc cargo
- flutter config --enable-linux-desktop
- git clone https://gitlab.com/veilid/veilid.git ../veilid
- flutter build linux
artifacts:
paths:
- build/linux/x64/release/bundle/
when: manual
build_linux_amd64_flatpak:
tags:
- saas-linux-small-amd64
image: ubuntu:23.04
stage: build_flatpak
dependencies: [build_linux_amd64_bundle]
script:
- apt-get update
- apt-get install -y --no-install-recommends flatpak flatpak-builder gnupg2 elfutils ca-certificates
- flatpak remote-add --no-gpg-verify --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
- flatpak install -y --noninteractive org.gnome.Sdk/x86_64/45 org.gnome.Platform/x86_64/45 app/org.flathub.flatpak-external-data-checker/x86_64/stable org.freedesktop.appstream-glib
- pushd flatpak/
- flatpak-builder --force-clean build-dir com.veilid.veilidchat.yml --repo=repo
- flatpak build-bundle repo com.veilid.veilidchat.flatpak com.veilid.veilidchat
- popd
artifacts:
paths:
- flatpak/com.veilid.veilidchat.flatpak
when: manual
#test:
# extends:
# - .macos_saas_runners
# stage: test
# script:
# - echo "place holder for test"

84
flatpak/README.md Normal file
View File

@ -0,0 +1,84 @@
- [Building the Flatpak](#building-the-flatpak)
- [Prerequisites](#prereq)
- [Build](#build)
- [Create Flatpak repo of the app](#create-flatpak-repo-of-the-app)
- [Publish to app store](#publish-to-app-store)
- [Bundle the Flatpak repo into an installable `.flatpak` file](#bundle-the-flatpak-repo-into-an-installable-flatpak-file)
- [We now have a `.flatpak` file that we can install on any machine with](#we-now-have-a-flatpak-file-that-we-can-install-on-any-machine-with)
- [We can see that it is installed:](#we-can-see-that-it-is-installed)
# Prerequisites
`flatpak install -y org.gnome.Platform/x86_64/45`
`flatpak install -y org.gnome.Sdk/x86_64/45`
# Building the Flatpak
We imagine this is a separate git repo containing the information specifically
for building the flatpak, as that is how an app is built for FlatHub.
Important configuration files are as follows:
- `com.veilid.veilidchat.yml` -- Flatpak manifest, contains the Flatpak
configuration and information on where to get the build files
- `build-flatpak.sh` -- Shell script that will be called by the manifest to assemble the flatpak
## Build
**This should be built on an older version on Linux so that it will run on the
widest possible set of Linux installations. Recommend docker or a CI pipeline
like GitHub actions using the oldest supported Ubuntu LTS.**
### Create Flatpak repo of the app
This is esentially what will happen when being built by FlatHub.
```bash
flatpak-builder --force-clean build-dir com.veilid.veilidchat.yml --repo=repo
```
#### Publish to app store
When this succeeds you can proceed to [submit to an app store like Flathub](https://github.com/flathub/flathub/wiki/App-Submission).
<br>
---
<br>
*The remainder is optional if we want to try installing locally, however only
the first step is needed to succeed in order to publish to FlatHub.*
### Bundle the Flatpak repo into an installable `.flatpak` file
This part is not done when building for FlatHub.
```bash
flatpak build-bundle repo com.veilid.veilidchat.flatpak com.veilid.veilidchat
```
### We now have a `.flatpak` file that we can install on any machine with
Flatpak:
```bash
flatpak install --user com.veilid.veilidchat.flatpak
```
### We can see that it is installed:
```bash
flatpak list --app | grep com.veilid.veilidchat
```
> Flutter App com.veilid.veilidchat 1.0.0 master flutterapp-origin user
If we search for "Flutter App" in the system application menu there should be an
entry for the app with the proper name and icon.
We can also uninstall our test flatpak:
```bash
flatpak remove com.veilid.veilidchat
```

41
flatpak/build-flatpak.sh Executable file
View File

@ -0,0 +1,41 @@
#!/bin/bash
# Convert the archive of the Flutter app to a Flatpak.
# Exit if any command fails
set -e
# Echo all commands for debug purposes
set -x
# No spaces in project name.
projectName=VeilidChat
projectId=com.veilid.veilidchat
executableName=veilidchat
# ------------------------------- Build Flatpak ----------------------------- #
# Copy the portable app to the Flatpak-based location.
cp -r bundle/ /app/$projectName
chmod +x /app/$projectName/$executableName
mkdir -p /app/bin
ln -s /app/$projectName/$executableName /app/bin/$executableName
# Install the icon.
iconDir=/app/share/icons/hicolor/256x256/apps
mkdir -p $iconDir
cp $projectId.png $iconDir/$projectId.png
# Install the desktop file.
desktopFileDir=/app/share/applications
mkdir -p $desktopFileDir
cp -r $projectId.desktop $desktopFileDir/
# Install the AppStream metadata file.
metadataDir=/app/share/metainfo
mkdir -p $metadataDir
cp -r $projectId.metainfo.xml $metadataDir/

View File

@ -0,0 +1,9 @@
#!/usr/bin/env xdg-open
[Desktop Entry]
Name=VeilidChat
Comment=VeilidChat Private Messaging
Exec=veilidchat
Icon=com.veilid.veilidchat
Terminal=false
Type=Application
Categories=Network;

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Generator for metainfo & .desktop files:
https://www.freedesktop.org/software/appstream/metainfocreator/#/
-->
<component type="desktop-application">
<id>com.veilid.veilidchat</id>
<name>VeilidChat</name>
<summary>VeilidChat Private Messaging</summary>
<developer_name>Veilid Foundation Inc</developer_name>
<url type="homepage">https://veilid.com/chat</url>
<metadata_license>MIT</metadata_license>
<project_license>MPL-2.0</project_license>
<supports>
<control>pointing</control>
<control>keyboard</control>
<control>touch</control>
</supports>
<description>
<p>TODO</p>
</description>
<launchable type="desktop-id">com.veilid.veilidchat.desktop</launchable>
<screenshots>
<screenshot type="default">
<image>TODO</image>
</screenshot>
</screenshots>
<content_rating type="oars-1.1" />
<releases>
<release version="0.1.2+4" date="2023-11-19" />
</releases>
</component>

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -0,0 +1,36 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/flatpak/flatpak-builder/main/data/flatpak-manifest.schema.json
---
app-id: com.veilid.veilidchat
runtime: org.gnome.Platform
runtime-version: "45"
sdk: org.gnome.Sdk
command: veilidchat
separate-locales: false
finish-args:
- --share=ipc
- --socket=fallback-x11
- --socket=wayland
- --device=dri
- --socket=pulseaudio
- --share=network
- --talk-name=org.freedesktop.secrets
modules:
- name: VeilidChat
buildsystem: simple
only-arches:
- x86_64
#- aarch64
build-commands:
- "./build-flatpak.sh"
sources:
- type: dir
path: ../build/linux/x64/release/
- type: file
path: build-flatpak.sh
- type: file
path: com.veilid.veilidchat.png
- type: file
path: com.veilid.veilidchat.desktop
- type: file
path: com.veilid.veilidchat.metainfo.xml