diff --git a/.github/workflows/flatpak.yml b/.github/workflows/flatpak.yml new file mode 100644 index 0000000000000..ae6f350813a28 --- /dev/null +++ b/.github/workflows/flatpak.yml @@ -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 }} diff --git a/.gitignore b/.gitignore index 37e27bfed9051..1a03288c0464f 100644 --- a/.gitignore +++ b/.gitignore @@ -118,6 +118,7 @@ compile_commands.json *.vcxproj* *.sln .vs/ +.flatpak-builder # Old irrlichtmt. Still ignored to make bisecting easier. lib/irrlichtmt diff --git a/net.minetest.minetest.yaml b/net.minetest.minetest.yaml new file mode 100644 index 0000000000000..0280f0c0db714 --- /dev/null +++ b/net.minetest.minetest.yaml @@ -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 "$@"'