Skip to content

Build your personal knowledge base with Trilium Notes

ci(flatpak): update the packaging repo from a workflow

Elian Doran4eb4c27e8275
diff --git a/.github/workflows/release-flathub.yml b/.github/workflows/release-flathub.yml
new file mode 100644
index 0000000000..7ae2409cf1
--- /dev/null
+++ b/.github/workflows/release-flathub.yml
@@ -0,0 +1,55 @@
+name: Release to Flathub
+on:
+ workflow_dispatch:
+ inputs:
+ ref:
+ description: 'Tag or ref to package (a tag pins tag + commit, anything else a bare commit)'
+ type: string
+ required: false
+
+permissions:
+ contents: read
+
+jobs:
+ update-flathub-repo:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v7
+ with:
+ ref: ${{ inputs.ref || github.ref }}
+ # update-repo.mts resolves the ref against the checkout, so tags must be present.
+ fetch-depth: 0
+
+ - uses: actions/setup-node@v7
+ with:
+ node-version: 24
+
+ - name: Install flatpak-node-generator
+ # Pinned to a master commit: there is no release, and bundled copies (org.flatpak.Builder)
+ # lag behind fixes such as skipping the linux-armv7l binaries Electron 44 dropped.
+ run: pipx install 'git+https://github.com/flatpak/flatpak-builder-tools.git@41c20aa10819cdb2a4f3ca171758a96d1955c018#subdirectory=node'
+
+ - name: Clone the Flathub repo
+ run: git clone --depth=1 https://github.com/flathub/org.triliumnotes.Trilium.git "$RUNNER_TEMP/flathub"
+
+ - name: Update the manifest and packaging files
+ run: node --experimental-strip-types scripts/flatpak/update-repo.mts "$RUNNER_TEMP/flathub" ${INPUT_REF:+"$INPUT_REF"}
+ env:
+ INPUT_REF: ${{ inputs.ref }}
+
+ - name: Generate the offline install sources
+ run: node --experimental-strip-types scripts/flatpak/generate-sources.mts "$RUNNER_TEMP/flathub"
+
+ - name: Validate the metainfo
+ run: |
+ sudo apt-get update
+ sudo apt-get install --yes appstream
+ appstreamcli validate --explain "$RUNNER_TEMP/flathub/org.triliumnotes.Trilium.metainfo.xml"
+
+ - name: Show the resulting change
+ run: git -C "$RUNNER_TEMP/flathub" --no-pager diff --stat
+
+ - uses: actions/upload-artifact@v7
+ with:
+ name: flathub-repo
+ path: ${{ runner.temp }}/flathub
diff --git a/apps/desktop/flatpak/flathub.json b/apps/desktop/flatpak/flathub.json
new file mode 100644
index 0000000000..4e6b2b83a1
--- /dev/null
+++ b/apps/desktop/flatpak/flathub.json
@@ -0,0 +1,4 @@
+{
+ "disable-external-data-checker": true,
+ "automerge-flathubbot-prs": false
+}
diff --git a/scripts/flatpak/update-repo.mts b/scripts/flatpak/update-repo.mts
index 18b2388d51..2408454ed3 100644
--- a/scripts/flatpak/update-repo.mts
+++ b/scripts/flatpak/update-repo.mts
@@ -1,6 +1,6 @@
/**
- * Writes the Flathub packaging repo's manifest and launch wrapper from their
- * vendored sources in `apps/desktop/flatpak/`, with the manifest's git source
+ * Writes the Flathub packaging repo's manifest, launch wrapper and bot config
+ * from their vendored sources in `apps/desktop/flatpak/`, with the git source
* pinned to the requested ref and its pnpm sources tracking that ref's
* `packageManager`. The desktop file and metainfo install from the pinned
* checkout itself; `generated-sources.json` is a separate step:
@@ -21,6 +21,9 @@ import { join, resolve } from "node:path";
const FLATPAK_DIR = join(import.meta.dirname, "../../apps/desktop/flatpak");
const MANIFEST_NAME = "org.triliumnotes.Trilium.yml";
+// The wrapper is a manifest source; flathub.json configures Flathub's bots and
+// only takes effect on the packaging repo's default branch.
+const COPIED_FILES = [ "trilium.sh", "flathub.json" ];
export async function main(argv: string[]) {
const [repoDirArg, ref = "HEAD"] = argv;
@@ -43,7 +46,9 @@ export async function main(argv: string[]) {
}
writeFileSync(join(repoDir, MANIFEST_NAME), manifest);
- copyFileSync(join(FLATPAK_DIR, "trilium.sh"), join(repoDir, "trilium.sh"));
+ for (const file of COPIED_FILES) {
+ copyFileSync(join(FLATPAK_DIR, file), join(repoDir, file));
+ }
console.log(`Updated ${repoDir}: ${tag ?? "beta"} @ ${commit}, pnpm ${pnpmVersion}.`);
}