Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Improve flatpak support #198

Merged
merged 9 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 37 additions & 3 deletions .github/workflows/flatpak.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Flatpak build
name: Flatpak CI

on:
release:
Expand All @@ -10,15 +10,49 @@ on:

jobs:
flatpak:
name: 'Flatpak build'
name: Flatpak build (${{ matrix.config.arch }})
runs-on: ubuntu-24.04
strategy:
matrix:
config:
- arch: x86_64
use_qemu: false

- arch: aarch64
use_qemu: true
qemu_arch: arm64
# Don't fail the whole workflow if one architecture fails
fail-fast: false
container:
image: bilelmoussaoui/flatpak-github-actions:freedesktop-24.08
options: --privileged
steps:
- uses: actions/checkout@v4

- name: Install deps
if: ${{ matrix.config.use_qemu == true }}
run: |
dnf -y install docker

- name: Set up QEMU
if: ${{ matrix.config.use_qemu == true }}
id: qemu
uses: docker/setup-qemu-action@v2
with:
platforms: ${{ matrix.config.qemu_arch }}

- uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v6
with:
bundle: oopetris.flatpak
manifest-path: com.github.mgerhold.OOPetris.yml
manifest-path: io.github.openbrickprotocolfoundation.oopetris.yml
verbose: ${{ runner.debug == '1' && 'true' || 'false' }}
cache-key: flatpak-builder-${{ github.sha }}
arch: ${{ matrix.config.arch }}

- uses: flatpak/flatpak-github-actions/flat-manager@v4
name: 'Deploy'
if: github.event_name != 'pull_request'
with:
repository: beta
flat-manager-url: http://flat-man.oopetris.totto.lt
token: ${{ secrets.FLAT_MANAGER_TOKEN }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: C++ lints(clang-format + clang-tidy)
name: Lint CI
on:
push:
branches: ['main']
Expand All @@ -7,6 +7,7 @@ on:

jobs:
cpp-linter:
name: C++ lints(clang-format + clang-tidy)
runs-on: ubuntu-24.04
permissions:
pull-requests: write
Expand All @@ -31,7 +32,7 @@ jobs:
- name: Prepare compile_commands.json
run: |
sudo apt-get update
sudo apt-get install ninja-build libsdl2-2.0-0 libsdl2-dev libsdl2-ttf* libsdl2-mixer* libsdl2-image* -y --no-install-recommends
sudo apt-get install ninja-build libsdl2-2.0-0 libsdl2-dev libsdl2-ttf* libsdl2-mixer* libsdl2-image* desktop-file-utils -y --no-install-recommends

meson setup build -Dbuildtype=release -Dclang_libcpp=disabled -Dtests=true
meson compile -C build git_version.hpp
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/musl.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: musl CI
name: Musl CI

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install ninja-build libsdl2-2.0-0 libsdl2-dev libsdl2-ttf* libsdl2-mixer* libsdl2-image* gcovr -y --no-install-recommends
sudo apt-get install ninja-build libsdl2-2.0-0 libsdl2-dev libsdl2-ttf* libsdl2-mixer* libsdl2-image* gcovr desktop-file-utils -y --no-install-recommends

- name: Configure
run: meson setup build -Dbuildtype=debug -Db_coverage=true -Dtests=true -Dclang_libcpp=enabled
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Installer CI
name: Windows Installer CI

on:
push:
Expand Down
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,21 @@ Or you can download and use prebuilt binaries from the CI-builds. You can find s

To download artifacts, click on the newest action and download the artifacts.

[Android](https://github.com/mgerhold/oopetris/actions/workflows/android.yml)
[Android](https://github.com/OpenBrickProtocolFoundation/oopetris/actions/workflows/android.yml)

[Linux (Flatpak)](https://github.com/mgerhold/oopetris/actions/workflows/flatpak.yml)
[Linux (Flatpak)](https://github.com/OpenBrickProtocolFoundation/oopetris/actions/workflows/flatpak.yml)

[Nintendo Switch /3DS](https://github.com/mgerhold/oopetris/actions/workflows/nintendo.yml)
[Nintendo Switch / 3DS](https://github.com/OpenBrickProtocolFoundation/oopetris/actions/workflows/nintendo.yml)

There is no correct Windows and MacOS build atm, you have to built it yourself or use the (maybe not published yet) release builds on github.
[Windows](https://github.com/OpenBrickProtocolFoundation/oopetris/actions/workflows/windows_installer.yml)

There is no correct MacOS build atm, you have to built it yourself or use the (maybe not published yet) releases on GitHub.

## Releases

There is an official website for OOPetris, where you also can find different links to auto updatable releases.

For concrete instructions see [here](docs/releases.md)

## Logo

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop-application">
<id>@APP_ID@</id>
<name>OOPetris</name>
<summary>A Tetris clone in OOP</summary>
<metadata_license>MIT</metadata_license>
<project_license>MIT</project_license>
<supports>
<control>pointing</control>
<control>keyboard</control>
<control>touch</control>
<control>gamepad</control>
</supports>
<description>
<p>
A Tetris clone in OOP. Supports multiplayer, recordings and many more features. For more information vist the github repository.
</p>
</description>
<launchable type="desktop-id">@[email protected]</launchable>
<content_rating type="oars-1.0" />
<developer id="lt.totto">
<name>Totto16</name>
</developer>
<releases>
<release version="0.5.6" date="2024-05-17">
<url type="details">https://github.com/OpenBrickProtocolFoundation/oopetris/releases/tag/0.5.6</url>
</release>
</releases>
<url type="homepage">https://oopetris.totto.lt/</url>
<url type="bugtracker">https://github.com/OpenBrickProtocolFoundation/oopetris/issues</url>
<url type="contribute">https://github.com/OpenBrickProtocolFoundation/oopetris/pulls</url>
<url type="vcs-browser">https://github.com/OpenBrickProtocolFoundation/oopetris</url>
</component>
5 changes: 1 addition & 4 deletions docs/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ For concrete instructions, see the list below:

## Linux

[linux](linux.md)
[Linux](linux.md)

## Serenity OS

[serenity](serenity.md)


## Windows

[windows](windows.md)
Expand All @@ -27,12 +26,10 @@ For concrete instructions, see the list below:

[switch](switch.md)


## Nintendo 3DS

[switch](3ds.md)


## Android

[android](android.md)
8 changes: 4 additions & 4 deletions docs/linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

You just have to call these commands:


```bash
meson setup build

Expand All @@ -19,14 +18,15 @@ meson compile -C build
./build/oopetris # to run the executable
```


## Compiling for flatpak

You optionally can compile a flatpak image.

For that you need some additional binaries, namely the flatpak-builder, than just run:

<!-- WIP: that is not entirely correct -->
> [!NOTE]
> that is not entirely correct
```bash
flatpak-build com.github.mgerhold.OOPetris.yml
flatpak-build io.github.openbrickprotocolfoundation.oopetris.yml
```
45 changes: 45 additions & 0 deletions docs/releases.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!-- LTeX: enabled=true, language=en -->

# OOPetris Releases


We support multiple platforms and different types of executables / packages.
So here is a list of supported "package managers" / installation platforms.

## Android / FDroid

> [!NOTE]
> This is still WIP

## Linux / Flatpak

We provide stable and beta releases via 2 remotes:

To use the stable version, use this repo:

```bash
flatpak remote-add --if-not-exists oopetris-stable https://oopetris.totto.lt/repo/assets/oopetris.stable.flatpakrepo

```

And to use beta version:

```bash
flatpak remote-add --if-not-exists oopetris-beta https://oopetris.totto.lt/repo/assets/oopetris.beta.flatpakrepo

```

Than install it by using this command:

```bash
flatpak install -v io.github.openbrickprotocolfoundation.oopetris
```

To update use the normal flatpak update command, keep in mind, that the bet may be unstable and break things, use with caution!

## Other

> [!NOTE]
> This is still WIP

All other platforms have more difficult to support auto update capabilities, so you can find more on our [website](https://oopetris.totto.lt/releases).
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
app-id: com.github.mgerhold.OOPetris
app-id: io.github.openbrickprotocolfoundation.oopetris
runtime: org.freedesktop.Platform
runtime-version: "24.08"
sdk: org.freedesktop.Sdk
Expand Down
2 changes: 1 addition & 1 deletion src/discord/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[[nodiscard]] std::string constants::discord ::get_asset_key(constants::discord::ArtAsset asset) {

switch (asset) {
case ArtAsset::logo:
case ArtAsset::Logo:
return "logo";
default:
UNREACHABLE();
Expand Down
6 changes: 4 additions & 2 deletions src/discord/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#pragma once

#include <core/helper/expected.hpp>
#include <core/helper/types.hpp>

#include "../helper/windows.hpp"

Expand All @@ -26,7 +27,8 @@ namespace constants::discord {
#elif defined(__CONSOLE__)
#error "Not supported"
#elif defined(FLATPAK_BUILD)
constexpr const char* platform_dependent_launch_arguments = "flatpak run com.github.mgerhold.OOPetris --discord";
constexpr const char* platform_dependent_launch_arguments =
"flatpak run io.github.openbrickprotocolfoundation.oopetris --discord";
#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
constexpr const char* platform_dependent_launch_arguments = "oopetris.exe --discord";
#elif defined(__APPLE__)
Expand All @@ -38,7 +40,7 @@ namespace constants::discord {
#endif

// manually synchronized to https://discord.com/developers/applications/1220147916371394650/rich-presence/assets
enum class ArtAsset { logo };
enum class ArtAsset : u8 { Logo };

OOPETRIS_GRAPHICS_EXPORTED [[nodiscard]] std::string get_asset_key(ArtAsset asset);

Expand Down
2 changes: 1 addition & 1 deletion src/scenes/main_menu/main_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ namespace scenes {

discord_instance->set_activity(
DiscordActivityWrapper("Selecting playmode", discord::ActivityType::Playing)
.set_large_image("Playing OOPetris", constants::discord::ArtAsset::logo)
.set_large_image("Playing OOPetris", constants::discord::ArtAsset::Logo)
.set_start_timestamp(std::chrono::system_clock::now())
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/scenes/replay_game/replay_game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace scenes {

discord_instance->set_activity(
DiscordActivityWrapper("Replaying a game", discord::ActivityType::Playing)
.set_large_image("Playing OOPetris", constants::discord::ArtAsset::logo)
.set_large_image("Playing OOPetris", constants::discord::ArtAsset::Logo)
.set_start_timestamp(std::chrono::system_clock::now())
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/scenes/single_player_game/single_player_game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace scenes {

discord_instance->set_activity(
DiscordActivityWrapper("Playing a single-player game", discord::ActivityType::Playing)
.set_large_image("Playing OOPetris", constants::discord::ArtAsset::logo)
.set_large_image("Playing OOPetris", constants::discord::ArtAsset::Logo)
.set_start_timestamp(std::chrono::system_clock::now())
);
}
Expand Down
13 changes: 11 additions & 2 deletions tools/dependencies/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ if build_application
endif

if is_flatpak_build
app_name = 'com.github.mgerhold.OOPetris'
app_name = 'io.github.openbrickprotocolfoundation.oopetris'

temp = core_lib.get('compile_args')
temp += '-DFLATPAK_BUILD'
Expand All @@ -319,6 +319,7 @@ if build_application
nfde_dep = dependency(
'nativefiledialog-extended',
required: not meson.is_cross_build(),
allow_fallback: true,
default_options: {
'xdg-desktop-portal': is_flatpak_build ? 'enabled' : 'auto',
},
Expand All @@ -336,9 +337,17 @@ if build_application

c = meson.get_compiler('c')

discord_dep_required = not meson.is_cross_build() and get_option('build_installer')

if host_machine.system() == 'linux' and host_machine.cpu_family() == 'aarch64'
# not supported on aarch64 linux :(
discord_dep_required = false
endif

discord_sdk_dep = dependency(
'discord-game-sdk',
required: not meson.is_cross_build() and get_option('build_installer'),
allow_fallback: true,
required: discord_dep_required,
# only with msvc we need a static library, all others work without adding __declspec() everywhere
static: c.get_id() == 'msvc',
default_options: c.get_id() != 'msvc' ? {} : {'default_library': 'static'},
Expand Down
Loading
Loading