-
Notifications
You must be signed in to change notification settings - Fork 254
Prepare repo for Flathub build process #2093
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
base: develop
Are you sure you want to change the base?
Changes from all commits
1e9e422
c0cea6a
821e86d
062ee42
6b18f81
0716e2b
0f627ec
665651d
193cf69
6775897
e675e7b
3f93abe
2ecfb6e
08caf4c
0607f7c
21a30a3
d96613c
66965c3
edeaa27
009d7fa
145025a
8d76306
cea0c1a
57bc370
5e149eb
f3d8f90
a7c37f3
bf79bae
9ff533b
dd6b0ef
3ff9e89
df7368e
9ff9eea
be4941e
df48723
f7d4b03
c9ab3cc
92e1f63
0cf1524
94d56d4
fe4a8d9
9008d06
9966f10
44f7ef6
006f51f
5efe5c8
140b6dc
4ce652c
d0e54aa
0f5a411
08ace1d
c66649e
b142743
b274648
43fc665
f6c80f4
7a69a45
bced53e
c11b0ae
52d2cee
35ec78b
782e9bd
ed2e005
81e6f7f
3edecc1
a17e90e
7ccafa5
f0bf5fe
187d531
6744189
c31bb8d
be7d068
21b6c7f
8e94ecf
67415b4
0f5f446
d68ed44
b6f1ffe
3a1120e
f649e98
1b6ddac
2a3a67a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| name: Build Flatpak | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| build-flatpak: | ||
| name: Build the Flatpak app | ||
| runs-on: ubuntu-latest | ||
| container: | ||
| image: ghcr.io/flathub-infra/flatpak-github-actions:freedesktop-25.08 | ||
| options: --privileged | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: jdx/mise-action@v3 | ||
| with: | ||
| install: true | ||
| cache: true | ||
| log_level: debug | ||
|
|
||
| - name: Install Yarn dependencies | ||
| run: yarn install --immutable | ||
|
|
||
| - name: Generate release manifest | ||
| run: yarn generate-release-manifest | ||
|
|
||
| - name: Generate node sources | ||
| run: yarn generate-node-sources | ||
|
|
||
| - name: Build flatpak | ||
| uses: flatpak/flatpak-github-actions/flatpak-builder@v6 | ||
| with: | ||
| bundle: r2modman.flatpak | ||
| manifest-path: flatpak/io.github.ebkr.r2modman.release.yaml |
TB516 marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [*] | ||
| indent_style=space | ||
| indent_size=2 |
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it'd be good to include a chain of steps involved in a release. EG:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the only extra step should be to update the metainfo.xml, but if there is a location that has the release steps, I'll update it real quick. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # r2modman Flatpak files | ||
|
|
||
| Files for the r2modman flatpak release. Contains all the files needed for a full Flathub release, or a standalone flatpak with a custom repository. | ||
|
|
||
| ## Directory breakdown | ||
|
|
||
| - [`io.github.ebkr.r2modman.yaml`](./io.github.ebkr.r2modman.yaml) is the Flatpak manifest that contains the instructions to build the Flatpak | ||
| - This manifest is the one committed to git, and is used for local development, as it gets the source code from the filesystem | ||
|
|
||
| - [`io.github.ebkr.r2modman.release.yaml`](./io.github.ebkr.r2modman.release.yaml) is a generated version of the manifest that is used in CI runners | ||
| - This manifest fetches the source code from a git repository and commit hash, and thus should NOT be committed to the repo, as it would need to be frequently updated for each release | ||
|
|
||
| - [`io.github.ebkr.r2modman.metainfo.xml`](./io.github.ebkr.r2modman.metainfo.xml) is the appstream metadata used by storefronts | ||
| - This metadata is mostly self sufficient, but should have a new release block added before a release is made (this will probably be done when updating the changelog and bumping versions) | ||
|
|
||
| - [`io.github.ebkr.r2modman.desktop`](./io.github.ebkr.r2modman.desktop) is the .desktop file that is distributed with the Flatpak and used to launch the app | ||
|
|
||
| - [`io.github.ebkr.r2modman`](./io.github.ebkr.r2modman) is a launch script that is used to run the r2modman binary inside of the Flatpak | ||
|
|
||
| - [`generated-sources.json`](./generated-sources.json) is a list of the yarn dependencies, formatted so they can be fetched by yarn during build time | ||
| - This file shouldn't be committed to the repo | ||
| - Flatpaks don't have network access while building, so the files are fetched before building starts | ||
| - This file is regenerated automatically when building locally, but a manual regeneration can be triggered via `yarn generate-node-sources` | ||
|
|
||
| - [`generate-release-manifest.js`](./generate-release-manifest.js) is a small script to take the manifest that is in the git repo, and update the sources to pull from git instead of using the local file system | ||
| - This script does use the `yaml` package, which is already used by r2modman, but this means you need to have ran `yarn install` at least once | ||
|
|
||
|
|
||
| ## Building locally | ||
|
|
||
| For building and installing locally, [Flatpak](https://flatpak.org/) and [Flatpak Builder](https://docs.flatpak.org/en/latest/flatpak-builder.html) are needed. For generating the node sources, `flatpak-node-generator` is invoked via pipx, so that is also needed. Additional tooling for linting related files can be gotten with the [`org.flatpak.Builder`](https://flathub.org/en/apps/org.flatpak.Builder) Flatpak. | ||
|
|
||
| ### Building | ||
|
|
||
| To build and install the Flatpak, the `yarn build-flatpak` command can be ran from the repository root. This script uses the `flatpak-builder` cli, along with `flatpak`, so make sure they are installed. | ||
|
|
||
| ### Linting | ||
|
|
||
| To lint the manifest, this command can be ran from the repository root: `flatpak run --command=flatpak-builder-lint org.flatpak.Builder manifest flatpak/io.github.ebkr.r2modman.yaml`. Some extra errors might come up due to the source code being fetched from a local directory, but this can be ignored as it is changed in the manifest used in CI. | ||
|
|
||
| To lint the appstream metainfo, this command can be ran from the repository root: `flatpak run --command=flatpak-builder-lint org.flatpak.Builder appstream flatpak/io.github.ebkr.r2modman.metainfo.xml` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # Flatpak release steps | ||
|
|
||
| There aren't many steps for the Flatpak/Flathub version to be released. The main steps to take are to prep the release, then, run the normal release workflow. This will trigger other workflows to generate a standalone Flatpak release (and eventually push to the Flathub repo). | ||
|
|
||
| ## Preparation | ||
|
|
||
| This assumes that version text and changelog has been updated already. | ||
|
|
||
| The only preparation required is to add the new release to the [metainfo.xml file](./io.github.ebkr.r2modman.metainfo.xml). | ||
|
|
||
| Full documentation for the releases section can be found [here](https://docs.flathub.org/docs/for-app-authors/metainfo-guidelines#release). | ||
|
|
||
| ### Required steps | ||
|
|
||
| 1. Go to the [metainfo.xml file](./io.github.ebkr.r2modman.metainfo.xml) | ||
| 2. Navigate to the `releases` xml tag | ||
| 3. Add a new `<release></release>` tag to the top of the list | ||
| 1. In this release tag, add a `version` attribute, corresponding to the app version | ||
| 2. Also in the release tag, add a `date` attribute, with the date of the release | ||
|
|
||
| Thats it! | ||
|
|
||
| ### Optional steps | ||
|
|
||
| - Add a `<description></description>` tag | ||
| - Write a short description of the changes and paste them here | ||
| - Add a `<url type="details"></url>` tag with a link to the current changelog | ||
|
|
||
| ## Release steps | ||
|
|
||
| Once the preparation is complete, then the release workflow can be ran, which will append a `.flatpak` file to the releases tag. | ||
|
|
||
| There will probably be more steps needed once a workflow to push to Flathub is added, but thats not currently implemented, so this documentation will be updated when its added. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| import fs from 'node:fs'; | ||
| import path from 'node:path'; | ||
| import process from 'node:process'; | ||
| import YAML from 'yaml'; | ||
|
|
||
| function fail(msg) { | ||
| console.error(msg); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| function parseArgs(argv) { | ||
| const args = { | ||
| input: null, | ||
| output: null, | ||
| repo: null, | ||
| commit: null, | ||
| }; | ||
|
|
||
| for (let i = 2; i < argv.length; i++) { | ||
| const arg = argv[i]; | ||
|
|
||
| if (arg === '--input') args.input = argv[++i]; | ||
| else if (arg === '--output') args.output = argv[++i]; | ||
| else if (arg === '--repo') args.repo = argv[++i]; | ||
| else if (arg === '--commit') args.commit = argv[++i]; | ||
| else fail(`Unknown argument: ${arg}`); | ||
| } | ||
|
|
||
| if (!args.input || !args.output || !args.repo || !args.commit) { | ||
| fail(` | ||
| Usage: | ||
| node generate-release-manifest.js \ | ||
| --input <path> \ | ||
| --output <path> \ | ||
| --repo <git-url> \ | ||
| --commit <sha> | ||
| `); | ||
| } | ||
|
|
||
| return args; | ||
| } | ||
|
|
||
| const { input, output, repo, commit } = parseArgs(process.argv); | ||
|
|
||
| const raw = fs.readFileSync(input, 'utf8'); | ||
|
|
||
| let manifest; | ||
|
|
||
| try { | ||
| manifest = YAML.parse(raw); | ||
| } catch { | ||
| fail('Invalid YAML manifest'); | ||
| } | ||
|
|
||
| if (!Array.isArray(manifest.modules)) { | ||
| fail('Manifest missing "modules"'); | ||
| } | ||
|
|
||
| const module = manifest.modules.find( | ||
| (m) => m && m.name === 'r2modmanPlus' | ||
| ); | ||
|
|
||
| if (!module) { | ||
| fail('Could not find module "r2modmanPlus"'); | ||
| } | ||
|
|
||
| if (!Array.isArray(module.sources) || module.sources.length === 0) { | ||
| fail('Module has no sources'); | ||
| } | ||
|
|
||
| const dirIndex = module.sources.findIndex((source) => { | ||
| return source.type === "dir" && source.path === ".."; | ||
| }); | ||
|
|
||
|
|
||
| module.sources[dirIndex] = { | ||
| type: 'git', | ||
| url: repo, | ||
| commit: commit, | ||
| }; | ||
|
|
||
| fs.mkdirSync(path.dirname(output), { recursive: true }); | ||
| fs.writeFileSync(output, YAML.stringify(manifest), 'utf8'); | ||
|
|
||
| console.log('Generated manifest:'); | ||
| console.log(` Input: ${input}`); | ||
| console.log(` Output: ${output}`); | ||
| console.log(` Repo: ${repo}`); | ||
| console.log(` Commit: ${commit}`); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| #!/bin/sh | ||
|
|
||
| if [ -n "$WAYLAND_DISPLAY" ]; then | ||
| exec zypak-wrapper /app/r2modman \ | ||
| --no-sandbox \ | ||
| --enable-features=UseOzonePlatform \ | ||
| --ozone-platform=wayland \ | ||
| "$@" | ||
| else | ||
| exec zypak-wrapper /app/r2modman --no-sandbox "$@" | ||
| fi |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| [Desktop Entry] | ||
| Type=Application | ||
|
|
||
| Name=r2modman | ||
| Comment=A simple and easy to use mod manager for many games using Thunderstore | ||
| Categories=Game;GameTool; | ||
|
|
||
| Icon=io.github.ebkr.r2modman | ||
| Exec=io.github.ebkr.r2modman | ||
| Terminal=false |
Uh oh!
There was an error while loading. Please reload this page.