Skip to content

Build your personal knowledge base with Trilium Notes

feat(ci): wire generation of flatpak sources when deps change & nightly

Elian Dorand6eb0cb424c6
diff --git a/.github/actions/generate-flatpak-sources/action.yml b/.github/actions/generate-flatpak-sources/action.yml
new file mode 100644
index 0000000000..a571f40117
--- /dev/null
+++ b/.github/actions/generate-flatpak-sources/action.yml
@@ -0,0 +1,26 @@
+name: "Generate Flatpak sources"
+description: "Runs flatpak-node-generator over pnpm-lock.yaml, producing upload/generated-sources.json"
+
+runs:
+ using: composite
+ steps:
+ - uses: actions/setup-node@v7
+ with:
+ node-version: 24
+
+ # The generator caches registry metadata per package, so a prefix hit from
+ # restore-keys spares re-fetching all ~2500 entries when a PR changes a few.
+ - name: Cache generator metadata
+ uses: actions/cache@v4
+ with:
+ path: ~/.cache/flatpak-node-generator
+ key: flatpak-node-generator-${{ hashFiles('pnpm-lock.yaml') }}
+ restore-keys: flatpak-node-generator-
+
+ - name: Install flatpak-node-generator
+ shell: bash
+ run: pipx install 'git+https://github.com/flatpak/flatpak-builder-tools.git#subdirectory=node'
+
+ - name: Generate the sources
+ shell: bash
+ run: node --experimental-strip-types ./scripts/generate-flatpak-sources.mts
diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml
index fdf3ba4fa5..29c9e66133 100644
--- a/.github/workflows/dev.yml
+++ b/.github/workflows/dev.yml
@@ -35,6 +35,7 @@ jobs:
server: ${{ steps.filter.outputs.server }}
standalone: ${{ steps.filter.outputs.standalone }}
ckeditor5: ${{ steps.filter.outputs.ckeditor5 }}
+ flatpak: ${{ steps.filter.outputs.flatpak }}
steps:
- uses: actions/checkout@v7
@@ -93,6 +94,33 @@ jobs:
- *workspace
- 'packages/ckeditor5/**'
- 'packages/commons/**'
+ # The flatpak sources file is derived from the lockfile alone; the
+ # root package.json pins the pnpm (and thus store) version the
+ # generation script asserts on.
+ flatpak:
+ - 'pnpm-lock.yaml'
+ - 'package.json'
+ - 'scripts/generate-flatpak-sources.mts'
+ - '.github/actions/generate-flatpak-sources/**'
+ - '.github/workflows/dev.yml'
+
+ flatpak_sources:
+ name: Check Flatpak sources generation
+ runs-on: ubuntu-latest
+ needs: changes
+ env:
+ AFFECTED: ${{ needs.changes.outputs.flatpak }}
+ steps:
+ - name: Checkout the repository
+ if: env.AFFECTED == 'true'
+ uses: actions/checkout@v7
+
+ # Exists to fail early: the release workflow runs the same action and
+ # blocks publishing on it, so a generator break should surface on the PR
+ # that causes it, not on the next tag.
+ - name: Generate the sources
+ if: env.AFFECTED == 'true'
+ uses: ./.github/actions/generate-flatpak-sources
test_dev:
name: Test development
diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml
index 69764cadb1..07787b5fd1 100644
--- a/.github/workflows/nightly.yml
+++ b/.github/workflows/nightly.yml
@@ -117,6 +117,37 @@ jobs:
name: TriliumNotes ${{ matrix.os.name }} ${{ matrix.arch }}
path: apps/desktop/upload
+ nightly-flatpak-sources:
+ if: ${{ github.repository == vars.REPO_MAIN }}
+ name: Generate Flatpak sources
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v7
+
+ # Daily canary for the unpinned flatpak-node-generator: a regression on its
+ # master branch shows up here overnight instead of on the next release tag.
+ - name: Generate the sources
+ uses: ./.github/actions/generate-flatpak-sources
+
+ - name: Publish release
+ uses: softprops/[email protected]
+ if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
+ with:
+ make_latest: false
+ prerelease: true
+ draft: false
+ fail_on_unmatched_files: true
+ files: upload/generated-sources.json
+ tag_name: nightly
+ name: Nightly Build
+
+ - name: Publish artifacts
+ uses: actions/upload-artifact@v7
+ if: ${{ github.event_name == 'pull_request' || github.ref != 'refs/heads/main' }}
+ with:
+ name: TriliumNotes flatpak sources
+ path: upload/generated-sources.json
+
nightly-mobile:
if: ${{ github.repository == vars.REPO_MAIN && github.event_name != 'pull_request' }}
name: Build mobile nightly
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index bd5fd1c3f6..f3628eb0a2 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -106,15 +106,8 @@ jobs:
steps:
- uses: actions/checkout@v7
- - uses: actions/setup-node@v7
- with:
- node-version: 24
-
- - name: Install flatpak-node-generator
- run: pipx install 'git+https://github.com/flatpak/flatpak-builder-tools.git#subdirectory=node'
-
- name: Generate the sources
- run: node --experimental-strip-types ./scripts/generate-flatpak-sources.mts
+ uses: ./.github/actions/generate-flatpak-sources
- name: Upload the artifact
uses: actions/upload-artifact@v7