Skip to content

Commit db54803

Browse files
authored
Merge pull request #10759 from nextcloud/chore/flatpakCi
feat(ci): add flatpak to CI
2 parents 0392321 + 3307084 commit db54803

7 files changed

Lines changed: 527 additions & 31 deletions
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
2+
# SPDX-License-Identifier: GPL-2.0-or-later
3+
name: Linux Flatpak Comment
4+
on:
5+
workflow_run:
6+
workflows: ["Linux Flatpak Package"]
7+
types: [completed]
8+
9+
jobs:
10+
comment-flatpak:
11+
name: Create a comment with a link to the built Flatpak
12+
runs-on: ubuntu-latest
13+
if: |-
14+
github.event.workflow_run.event == 'pull_request' &&
15+
github.event.workflow_run.conclusion == 'success'
16+
steps:
17+
- name: Comment Flatpak
18+
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
19+
with:
20+
github-token: ${{ secrets.GITHUB_TOKEN }}
21+
script: |
22+
// Discover the origin pull request ID.
23+
// Since GitHub does not include any pull requests from forks as part of a WorkflowRun we need to look up the PR ourselves.
24+
const pullRequestsForThisBranch = await github.rest.repos.listPullRequestsAssociatedWithCommit({
25+
owner: context.payload.workflow_run.head_repository.owner.login,
26+
repo: context.payload.workflow_run.head_repository.name,
27+
commit_sha: context.payload.workflow_run.head_branch,
28+
});
29+
const latestPullRequest = pullRequestsForThisBranch.data.sort((a, b) => b.id - a.id)[0];
30+
if (!latestPullRequest) {
31+
console.log("Could not find recent pull request related to this workflow run");
32+
return;
33+
};
34+
const prId = latestPullRequest.number;
35+
console.log(`Discovered pull request #${prId}`);
36+
37+
const workflowArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
38+
owner: context.repo.owner,
39+
repo: context.repo.repo,
40+
run_id: context.payload.workflow_run.id,
41+
});
42+
const artifact = workflowArtifacts.data.artifacts.filter((artifact) => artifact.name == "com.nextcloud.desktopclient.nextcloud.flatpak")[0];
43+
44+
if (!artifact) {
45+
console.log("Could not find matching artifact");
46+
return;
47+
}
48+
49+
// artifact.url and artifact.archive_download_url contain a URL that's supposed to be used by API clients only
50+
const artifactUrl = `https://github.com/nextcloud/desktop/actions/runs/${artifact.workflow_run.id}/artifacts/${artifact.id}`;
51+
52+
const comment_identifier_string = "<!-- automated comment for a flatpak build -->";
53+
54+
const comment_body = `
55+
${comment_identifier_string}
56+
57+
Artifact containing the Flatpak bundle: [${artifact.name}.zip](${artifactUrl})
58+
59+
Digest: \`${artifact.digest}\`
60+
61+
To test this change/fix you can download the above artifact file, unzip it, and install the bundle with:
62+
\`flatpak install --user ${artifact.name}\`
63+
64+
Please make sure to quit your existing Nextcloud app and backup your data.
65+
`;
66+
67+
console.log("fetching old comments")
68+
const comments = await github.rest.issues.listComments({
69+
owner: context.repo.owner,
70+
repo: context.repo.repo,
71+
issue_number: prId,
72+
});
73+
74+
comments
75+
.data
76+
.filter(comment => comment.body?.includes(comment_identifier_string))
77+
.forEach(comment => {
78+
console.log(`deleting previous Flatpak comment with ID ${comment.id}`)
79+
github.rest.issues.deleteComment({
80+
owner: context.repo.owner,
81+
repo: context.repo.repo,
82+
comment_id: comment.id,
83+
})
84+
});
85+
86+
console.log("creating new comment")
87+
github.rest.issues.createComment({
88+
owner: context.repo.owner,
89+
repo: context.repo.repo,
90+
issue_number: prId,
91+
body: comment_body,
92+
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
2+
# SPDX-License-Identifier: GPL-2.0-or-later
3+
name: Linux Flatpak Package
4+
on:
5+
pull_request:
6+
types: [opened, reopened, synchronize, ready_for_review, closed]
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
flatpak:
14+
if: ${{ github.event.action != 'closed' && !github.event.pull_request.draft }}
15+
name: Linux Flatpak Package
16+
runs-on: ubuntu-latest
17+
container:
18+
image: ghcr.io/flathub-infra/flatpak-github-actions:gnome-48
19+
options: --privileged
20+
steps:
21+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
22+
- uses: flatpak/flatpak-github-actions/flatpak-builder@79327416609af08178ad73b352877e51450790b3 # v6.8
23+
with:
24+
bundle: com.nextcloud.desktopclient.nextcloud.flatpak
25+
manifest-path: admin/linux/flatpak/com.nextcloud.desktopclient.nextcloud.yml
26+
upload-artifact: true
27+
artifact-name: com.nextcloud.desktopclient.nextcloud.flatpak
28+
build-bundle: true

0 commit comments

Comments
 (0)