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

Build Flatpak in CI #14673

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from
57 changes: 57 additions & 0 deletions .github/workflows/flatpak.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
name: flatpak

on:
push:
branches: [ "master" ]
tags: [ "*" ]
pull_request:
workflow_dispatch:
inputs:
use_cache:
description: "Use build cache"
required: true
type: boolean
default: true

permissions:
id-token: write
contents: read
attestations: write

jobs:
build:
runs-on: ubuntu-latest
container:
image: bilelmoussaoui/flatpak-github-actions:freedesktop-23.08
options: --privileged
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Determine output file name
run: |
add_commit=${{ !startsWith(github.ref, 'refs/tags/') }}
major=$(grep -oP 'VERSION_MAJOR\s+\K\d+' CMakeLists.txt)
minor=$(grep -oP 'VERSION_MINOR\s+\K\d+' CMakeLists.txt)
patch=$(grep -oP 'VERSION_PATCH\s+\K\d+' CMakeLists.txt)
file_name="Minetest-$major.$minor.$patch$([[ "$add_commit" != "false" ]] && echo "-$(echo ${{ github.sha }} | cut -c 1-7)").flatpak"
echo "File name: $file_name"
echo "FILE_NAME=$file_name" >> $GITHUB_ENV
shell: bash

- name: Build Flatpak
uses: flatpak/flatpak-github-actions/flatpak-builder@master
with:
arch: x86_64
bundle: ${{ env.FILE_NAME }}
manifest-path: net.minetest.minetest.yaml
cache-key: flatpak-builder-${{ github.sha }}
restore-cache: ${{ (github.event_name == 'workflow_dispatch' && inputs.use_cache) || !startsWith(github.ref, 'refs/tags/') }}
upload-artifact: true

- name: Generate artifact attestation
if: ${{ github.event_name != 'pull_request' }}
uses: actions/attest-build-provenance@v1
with:
subject-path: ${{ env.FILE_NAME }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ compile_commands.json
*.vcxproj*
*.sln
.vs/
.flatpak-builder

# Old irrlichtmt. Still ignored to make bisecting easier.
lib/irrlichtmt
Expand Down
56 changes: 56 additions & 0 deletions net.minetest.minetest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
$schema: "https://raw.githubusercontent.com/flatpak/flatpak-builder/main/data/flatpak-manifest.schema.json"
app-id: net.minetest.minetest
runtime: org.freedesktop.Platform
runtime-version: "23.08"
sdk: org.freedesktop.Sdk
command: minetest
rename-icon: minetest
finish-args:
- "--socket=wayland"
- "--socket=fallback-x11"
- "--socket=pulseaudio"
- "--device=all"
- "--share=ipc"
- "--share=network"
cleanup:
- "/include"
- "/lib/pkgconfig"
- "/share/aclocal"
- "/share/gtk-doc"
- "/share/man"
- "*.la"
- "*.a"

modules:
- name: libluajit
no-autogen: true
make-args:
- PREFIX=/app
make-install-args:
- PREFIX=/app
cleanup:
- "/bin"
sources:
- type: git
url: https://github.com/LuaJIT/LuaJIT.git
commit: dad04f1754723e76ba9dcf9f401f3134a0cd3972

- name: minetest
buildsystem: cmake-ninja
config-opts:
- "-DENABLE_CURSES=0"
- "-DENABLE_GETTEXT=1"
cleanup:
- "/share/minetest/games/devtest"
post-install:
- mv $FLATPAK_DEST/bin/minetest $FLATPAK_DEST/bin/minetest.bin
- install -Dm755 minetest.sh $FLATPAK_DEST/bin/minetest
sources:
- type: dir
path: .

- type: script
dest-filename: minetest.sh
commands:
- 'MINETEST_USER_PATH=$HOME/.var/app/net.minetest.minetest/.minetest exec minetest.bin "$@"'
Loading