Project Icon

flatpak-github-actions

Flatpak应用的GitHub Actions自动化构建与部署方案

flatpak-github-actions是一个开源项目,为开发者提供在GitHub Actions中自动构建和部署Flatpak应用的工具。该项目支持多架构构建、自动化测试和远程部署,并提供丰富的配置选项。通过预配置的Docker镜像,项目支持GNOME、KDE等主流Linux桌面环境的运行时,简化了Flatpak应用的CI/CD流程。

Flatpak GitHub Actions

Build and deploy your Flatpak application using GitHub Actions

Flatpak logo

CI

How to use

Building stage

Add a new workflow by creating a .yml file under .github/workflows with this content

on:
  push:
    branches: [main]
  pull_request:
name: CI
jobs:
  flatpak:
    name: "Flatpak"
    runs-on: ubuntu-latest
    container:
      image: bilelmoussaoui/flatpak-github-actions:gnome-44
      options: --privileged
    steps:
    - uses: actions/checkout@v4
    - uses: flatpak/flatpak-github-actions/flatpak-builder@v6
      with:
        bundle: palette.flatpak
        manifest-path: org.gnome.zbrown.Palette.yml
        cache-key: flatpak-builder-${{ github.sha }}

Inputs

NameDescriptionRequiredDefault
manifest-pathThe relative path of the manifest fileRequired-
stop-at-moduleStop at the specified module, ignoring it and all the following ones. Using this option disables generating bundles.OptionalBuild all modules from the manifest file
bundleThe bundle nameOptionalapp.flatpak
build-bundleWhether to build a bundle or notOptionaltrue
repository-nameThe repository name, used to fetch the runtime when the user download the Flatpak bundle or when building the applicationOptionalflathub
repository-urlThe repository url, used to fetch the runtime when the user download the Flatpak bundle or when building the applicationOptionalhttps://flathub.org/repo/flathub.flatpakrepo
run-testsEnable/Disable running tests. This overrides the flatpak-builder option of the same name, which invokes make check or ninja test. Network and X11 access is enabled, with a display server provided by xvfb-run.Optionalfalse
branchThe default flatpak branchOptionalmaster
cacheEnable/Disable caching .flatpak-builder directoryOptionaltrue
restore-cacheEnable/Disable cache restoring. If caching is enabled.Optionaltrue
cache-keySpecifies the cache key. CPU arch is automatically added, so there is no need to add it to the cache key.Optionalflatpak-builder-${sha256(manifestPath)}
archSpecifies the CPU architecture to build forOptionalx86_64
mirror-screenshots-urlSpecifies the URL to mirror screenshotsOptional-
gpg-signThe key to sign the packageOptional-
verboseEnable verbosityOptionalfalse
upload-artifactWhether to upload the resulting bundle or not as an artifactOptionaltrue

Building for multiple CPU architectures

To build for CPU architectures other than x86_64, the GitHub Actions workflow has to either natively be running on that architecture (e.g. on an aarch64 self-hosted GitHub Actions runner), or the container used must be configured to emulate the requested architecture (e.g. with QEMU).

For example, to build a Flatpak for both x86_64 and aarch64 using emulation, use the following workflow as a guide:

on:
  push:
    branches: [main]
  pull_request:
name: CI
jobs:
  flatpak:
    name: "Flatpak"
    runs-on: ubuntu-latest
    container:
      image: bilelmoussaoui/flatpak-github-actions:gnome-44
      options: --privileged
    strategy:
      matrix:
        arch: [x86_64, aarch64]
      # Don't fail the whole workflow if one architecture fails
      fail-fast: false
    steps:
    - uses: actions/checkout@v4
    # Docker is required by the docker/setup-qemu-action which enables emulation
    - name: Install deps
      if: ${{ matrix.arch != 'x86_64' }}
      run: |
        dnf -y install docker
    - name: Set up QEMU
      if: ${{ matrix.arch != 'x86_64' }}
      id: qemu
      uses: docker/setup-qemu-action@v2
      with:
        platforms: arm64
    - uses: flatpak/flatpak-github-actions/flatpak-builder@v6
      with:
        bundle: palette.flatpak
        manifest-path: org.gnome.zbrown.Palette.yml
        cache-key: flatpak-builder-${{ github.sha }}
        arch: ${{ matrix.arch }}

Building for Automated Tests

As described in the Inputs documentation, specifying run-tests: true will amend the Flatpak manifest to enable Network and X11 access automatically. Any other changes to the manifest must be made manually, such as building the tests (e.g. -Dtests=true) or any other options (e.g. --buildtype=debugoptimized).

Most developers will want to run tests on pull requests, before merging into the main branch of a repository. To ensure your manifest is building the correct code, you should set the sources entry for your project to "type": "dir" with the path key relative to the manifest's location in the repository.

In the example below, the manifest is located at /build-aux/flatpak/org.gnome.zbrown.Palette.json, so the path key is set to ../../. If the manifest were in the project root instead, the correct usage would be "path": "./".

{
    "app-id" : "org.gnome.zbrown.Palette",
    "runtime" : "org.gnome.Platform",
    "runtime-version" : "master",
    "sdk" : "org.gnome.Sdk",
    "command" : "org.gnome.zbrown.Palette",
    "finish-args" : [
        "--share=ipc",
        "--device=dri",
        "--socket=fallback-x11",
        "--socket=wayland"
    ],
    "modules" : [
        {
            "name" : "palette",
            "buildsystem" : "meson",
            "config-opts" : [
                "--prefix=/app",
                "--buildtype=debugoptimized",
                "-Dtests=true"
            ],
            "sources" : [
                {
                    "name" : "palette",
                    "buildsystem" : "meson",
                    "type" : "dir",
                    "path" : "../../"
                }
            ]
        }
    ]
}

Deployment stage

If you want to deploy the successfully built Flatpak application to a remote repository

on:
  push:
    branches: [main]
name: Deploy
jobs:
  flatpak:
    name: "Flatpak"
    runs-on: ubuntu-latest
    container:
      image: bilelmoussaoui/flatpak-github-actions:gnome-44
      options: --privileged
    steps:
    - uses: actions/checkout@v4
    - uses: flatpak/flatpak-github-actions/flatpak-builder@v6
      name: "Build"
      with:
        bundle: palette.flatpak
        manifest-path: org.gnome.zbrown.Palette.yml
        cache-key: flatpak-builder-${{ github.sha }}
    - uses: flatpak/flatpak-github-actions/flat-manager@v6
      name: "Deploy"
      with:
        repository: elementary
        flat-manager-url: https://flatpak-api.elementary.io
        token: some_very_hidden_token
        end-of-life: "The application has been renamed to..."
        end-of-life-rebase: "org.zbrown.Palette"

Inputs

NameDescriptionRequiredDefault
repositoryThe repository to push the build intoRequired-
flat-manager-urlThe flat-manager remote URLRequired-
tokenA flat-manager tokenRequired-
end-of-lifeReason for end of lifeOptional-
end-of-life-rebaseThe new app-idOptional-
build-log-urlURL to Flatpak build logOptional-
verboseEnable verbosityOptionalfalse

Docker Image

The Docker image used for the action consists of 2 parts: The base image, based on Fedora and which can be found here, and the specific image of the runtime you choose, which is generated through this GitHub Actions workflow.

You can specify the specific runtime you need to use through the image tags:

RuntimeVersionTagExample
Freedesktop SDK20.08freedesktop-20.08image: bilelmoussaoui/flatpak-github-actions:freedesktop-20.08
Freedesktop SDK21.08freedesktop-21.08image: bilelmoussaoui/flatpak-github-actions:freedesktop-21.08
Freedesktop SDK22.08freedesktop-22.08image: bilelmoussaoui/flatpak-github-actions:freedesktop-22.08
Freedesktop SDK23.08freedesktop-23.08image: bilelmoussaoui/flatpak-github-actions:freedesktop-23.08
GNOME3.38gnome-3.38image: bilelmoussaoui/flatpak-github-actions:gnome-3.38
GNOME40gnome-40image: bilelmoussaoui/flatpak-github-actions:gnome-40
GNOME41gnome-41image: bilelmoussaoui/flatpak-github-actions:gnome-41
GNOME42gnome-42image: bilelmoussaoui/flatpak-github-actions:gnome-42
GNOME43gnome-43image: bilelmoussaoui/flatpak-github-actions:gnome-43
GNOME44gnome-44image: bilelmoussaoui/flatpak-github-actions:gnome-44
GNOME45gnome-45image: bilelmoussaoui/flatpak-github-actions:gnome-45
GNOME46gnome-46image: bilelmoussaoui/flatpak-github-actions:gnome-46
GNOMEmastergnome-nightlyimage: bilelmoussaoui/flatpak-github-actions:gnome-nightly
KDE5.15kde-5.15image: bilelmoussaoui/flatpak-github-actions:kde-5.15
KDE5.15-21.08kde-5.15-21.08image: bilelmoussaoui/flatpak-github-actions:kde-5.15-21.08
KDE5.15-22.08kde-5.15-22.08image: bilelmoussaoui/flatpak-github-actions:kde-5.15-22.08
KDE5.15-23.08kde-5.15-23.08image: bilelmoussaoui/flatpak-github-actions:kde-5.15-23.08
KDE6.2kde-6.2image: bilelmoussaoui/flatpak-github-actions:kde-6.2
KDE6.3kde-6.3image: bilelmoussaoui/flatpak-github-actions:kde-6.3
KDE6.4kde-6.4image: bilelmoussaoui/flatpak-github-actions:kde-6.4
KDE6.5kde-6.5image: bilelmoussaoui/flatpak-github-actions:kde-6.5
KDE6.6kde-6.6image: bilelmoussaoui/flatpak-github-actions:kde-6.6
KDE6.7kde-6.7image: bilelmoussaoui/flatpak-github-actions:kde-6.7
elementary BaseAppjunojunoimage: bilelmoussaoui/flatpak-github-actions:elementary-juno
项目侧边栏1项目侧边栏2
推荐项目
Project Cover

豆包MarsCode

豆包 MarsCode 是一款革命性的编程助手,通过AI技术提供代码补全、单测生成、代码解释和智能问答等功能,支持100+编程语言,与主流编辑器无缝集成,显著提升开发效率和代码质量。

Project Cover

AI写歌

Suno AI是一个革命性的AI音乐创作平台,能在短短30秒内帮助用户创作出一首完整的歌曲。无论是寻找创作灵感还是需要快速制作音乐,Suno AI都是音乐爱好者和专业人士的理想选择。

Project Cover

白日梦AI

白日梦AI提供专注于AI视频生成的多样化功能,包括文生视频、动态画面和形象生成等,帮助用户快速上手,创造专业级内容。

Project Cover

有言AI

有言平台提供一站式AIGC视频创作解决方案,通过智能技术简化视频制作流程。无论是企业宣传还是个人分享,有言都能帮助用户快速、轻松地制作出专业级别的视频内容。

Project Cover

Kimi

Kimi AI助手提供多语言对话支持,能够阅读和理解用户上传的文件内容,解析网页信息,并结合搜索结果为用户提供详尽的答案。无论是日常咨询还是专业问题,Kimi都能以友好、专业的方式提供帮助。

Project Cover

讯飞绘镜

讯飞绘镜是一个支持从创意到完整视频创作的智能平台,用户可以快速生成视频素材并创作独特的音乐视频和故事。平台提供多样化的主题和精选作品,帮助用户探索创意灵感。

Project Cover

讯飞文书

讯飞文书依托讯飞星火大模型,为文书写作者提供从素材筹备到稿件撰写及审稿的全程支持。通过录音智记和以稿写稿等功能,满足事务性工作的高频需求,帮助撰稿人节省精力,提高效率,优化工作与生活。

Project Cover

阿里绘蛙

绘蛙是阿里巴巴集团推出的革命性AI电商营销平台。利用尖端人工智能技术,为商家提供一键生成商品图和营销文案的服务,显著提升内容创作效率和营销效果。适用于淘宝、天猫等电商平台,让商品第一时间被种草。

Project Cover

AIWritePaper论文写作

AIWritePaper论文写作是一站式AI论文写作辅助工具,简化了选题、文献检索至论文撰写的整个过程。通过简单设定,平台可快速生成高质量论文大纲和全文,配合图表、参考文献等一应俱全,同时提供开题报告和答辩PPT等增值服务,保障数据安全,有效提升写作效率和论文质量。

投诉举报邮箱: service@vectorlightyear.com
@2024 懂AI·鲁ICP备2024100362号-6·鲁公网安备37021002001498号